# Run dynamo definition in multiple files

**URL:** <https://forum.dynamobim.com/t/run-dynamo-definition-in-multiple-files/763>\
**Category:** Packages\
**Created:** [November 30, 2014, 7:13pm UTC](https://forum.dynamobim.com/t/run-dynamo-definition-in-multiple-files/763 "2014-11-30T19:13:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maciej\_Wypych](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Maciej\_Wypych](https://forum.dynamobim.com/u/Maciej_Wypych)\
**Post date:** [November 30, 2014, 7:13pm UTC](https://forum.dynamobim.com/t/run-dynamo-definition-in-multiple-files/763/1 "2014-11-30T19:13:56Z")

</div>

Hi,

I’ve created a set of dynamo definition to help with management of our family library (rename materials, set parameters, etc…) Works great, but it requires to open each file one by one and each time open Dynamo.

I was wandering is it actually possible to run a dynamo definition in multiple files?

First I was thinking about trying to create a macro to open files, open dynamo and run a definition, but with my limited coding skills it’s a bit too complicated.

Then I thought to create a code block with python script in Dynamo ,as there is no node to open a Revit Project/Family file, but I’m not sure how to tell Dynamo to switch between files.

Is it a lost cause? Or is it possible?

Thanks,

Maciej

---

<div class="post-metadata">

**Author:** ![Ritesh\_Chandawar](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@Ritesh\_Chandawar](https://forum.dynamobim.com/u/Ritesh_Chandawar)\
**Post date:** [November 30, 2014, 8:57pm UTC](https://forum.dynamobim.com/t/run-dynamo-definition-in-multiple-files/763/2 "2014-11-30T20:57:30Z")

</div>

Hello [Maciej Wypych](http://dynamobim.com/forums/users/maciejwoselarch-co-uk/ "View Maciej Wypych's profile"),

If you put your .DYF(definitions file) in following location then every-time when you launch Dynamo it will load those definitions in Library and from there you can access those definitions on every dyn file.

copy/paste you dyf here (C:\Users\<strong\>you user name\AppData\Roaming\Dynamo\0.7\packages)

Do let me know if that doesn’t work for you.

Thanks,

Ritesh

&nbsp;

---

<div class="post-metadata">

**Author:** ![Maciej\_Wypych](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Maciej\_Wypych](https://forum.dynamobim.com/u/Maciej_Wypych)\
**Post date:** [November 30, 2014, 11:25pm UTC](https://forum.dynamobim.com/t/run-dynamo-definition-in-multiple-files/763/3 "2014-11-30T23:25:12Z")

</div>

Hi Ritesh,

Thank you for your reply, but it seems that I wasn’t clear enough explaining my problem.

I know how to re-use the definition in different Dynamo files.

I’d like to know if you can run a Dynamo definition in multiple Revit files without opening each Revit file one by one. Or at least get away without re-opening Dynamo each time the new file is loaded to point to the current document.

&nbsp;

Kind Regards,

Maciej

&nbsp;

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [December 1, 2014, 12:06am UTC](https://forum.dynamobim.com/t/run-dynamo-definition-in-multiple-files/763/4 "2014-12-01T00:06:23Z")

</div>

Hi Maciej,

What you’re aiming to do sounds like a tall order. I’m not sure if it’s possible to open documents from inside Dynamo. However if you open them before you start Dynamo, you can query all open documents the following way:

![2014-12-01_132800](http://dynamobim.com/wp-content/uploads/forum-assets/dimiter_vmail-bg/12/01/2014-12-01_132800-300x241.jpg)

&nbsp;

So if you manage to convert all your tasks in a single definition as Ritesh suggested, and you make it so that it expects a document as an input every time, you should technically be able to apply all your tasks to each document opened in the UI.

EDIT:

It seems you can also open files from macros: [http://thebuildingcoder.typepad.com/blog/2010/03/using-processstart-to-open-a-project-or-family.html](http://thebuildingcoder.typepad.com/blog/2010/03/using-processstart-to-open-a-project-or-family.html)

I replicated the functionality in Dynamo, but it seems to be a tad unstable sometimes.

[OpenDocs](http://dynamobim.com/wp-content/uploads/forum-assets/dimiter_vmail-bg/12/01/OpenDocs.dyn)

![2014-12-01_141525](http://dynamobim.com/wp-content/uploads/forum-assets/dimiter_vmail-bg/12/01/2014-12-01_141525-300x223.jpg)

Now the final piece of the puzzle seems to be the functionality to lock the current document.

---

<div class="post-metadata">

**Author:** ![Maciej\_Wypych](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Maciej\_Wypych](https://forum.dynamobim.com/u/Maciej_Wypych)\
**Post date:** [December 1, 2014, 4:42pm UTC](https://forum.dynamobim.com/t/run-dynamo-definition-in-multiple-files/763/5 "2014-12-01T16:42:30Z")

</div>

Hi Dimitar,

Thank you so much. It’s really a great help.

That just made my day 🙂

Kind Regards,

Maciej

---

<div class="post-metadata">

**Author:** ![Andreas\_Dieckmann](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andreas_dieckmann/32/365_2.png) [@Andreas\_Dieckmann](https://forum.dynamobim.com/u/Andreas_Dieckmann)\
**Post date:** [December 2, 2014, 12:38am UTC](https://forum.dynamobim.com/t/run-dynamo-definition-in-multiple-files/763/6 "2014-12-02T00:38:18Z")

</div>

If you’re looking for a way to batch process a large amount of project or family files, you should have a look at the Revit Test Framework:

> **[DynamoDS/RevitTestFramework](https://github.com/DynamoDS/RevitTestFramework)**
>
> Unit Testing on Revit. Contribute to DynamoDS/RevitTestFramework development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Nick\_Curtis](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_curtis/32/24343_2.png) [@Nick\_Curtis](https://forum.dynamobim.com/u/Nick_Curtis)\
**Post date:** [September 22, 2015, 5:19pm UTC](https://forum.dynamobim.com/t/run-dynamo-definition-in-multiple-files/763/7 "2015-09-22T17:19:55Z")

</div>

Hello Ritesh,

This is a much delayed reply to this thread,but…

With regard to your response about the definitions library, are there any alternative approaches that would allow a different user to open the file (a user without the custom node definitions in their local folder) and have full functionality? Is there a way to “bake” custom nodes into a .dyn file? Or alternatively, is there a way to define functions by codeblock that can return multiple outputs?

Best regards,

Nick

---

<div class="post-metadata">

**Author:** ![Antony\_Mcphee](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@Antony\_Mcphee](https://forum.dynamobim.com/u/Antony_Mcphee)\
**Post date:** [March 17, 2016, 9:58pm UTC](https://forum.dynamobim.com/t/run-dynamo-definition-in-multiple-files/763/8 "2016-03-17T21:58:45Z")

</div>

This is the only post I could find on this issue.

I tried Dimitar’s pythonscript with 2 families and a project open but got an error:

`docs = Application().Documents` returns null.

Even so I don’t really understand how you would use it to run a Dynamo node across multiple files:

- How do you make a node use the document you feed it instead of the current document?
- Or how can you change documents and point Dynamo to it? (If you change focus to a different file with Dynamo open it clams up and says "Dynamo is not pointing to the current document". Clicking in the workspace changes focus but is there a node to do that?)

This post started with an earlier version of Dynamo, does 0.91 makes any difference?

Dynamo now takes ages to load so having to close and open it to run one routine in multiple files has become very time consuming.

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [March 17, 2016, 11:48pm UTC](https://forum.dynamobim.com/t/run-dynamo-definition-in-multiple-files/763/9 "2016-03-17T23:48:26Z")

</div>

Hi Antohy,

That’s currently not possible out of the box. You’ll have to script that interaction yourself.

However Andreas Dieckmann made this wonderful package called “Dynamo Automation” that greatly simplifies the process of running a dynamo graph on multiple projects:

> **[andydandy74/DynamoAutomation](https://github.com/andydandy74/DynamoAutomation)**
>
> Batch-processing of Revit models using the Dynamo visual programming environment - andydandy74/DynamoAutomation

Not sure why 0.91 is taking so long to launch for you. I haven’t noticed any slowdowns on my side.

&nbsp;
