-
Notifications
You must be signed in to change notification settings - Fork 23
Master Graphs
A master graph makes use of a number of nodes from the DynamoAutomation package. It always contains the following parts (depending on the complexity of the operation there can be multiple similar instances of those parts, i.e. when utilising multiple slave graphs):
The first thing we'll need is a list of models to process. Depending on the scenario the method of acquiring the list of models may vary:
-
Browsing directories: This is easy enough with Dynamo's built-in functionality. (If you need to process a directory recursively, use Clockwork's
Directory.ContentsAll
node.) - Extracting paths from CSV or Excel files: This also works fine with built-in nodes. (For some more versatile Excel nodes have a look at package BumbleBee.)
- Extracting paths from a database: Use package Slingshot for accessing databases with Dynamo.
-
Extracting paths from linked models: Use
Get Documents
from package archi-lab.net - Combinations of the above methods: Scenario A2 is a good example for that (extracting directory paths from a CSV file and subsequently browsing them).
Note that if you are processing a list of specific file locations (i.e. not browsing entire directories) make sure to have Dynamo test whether the files actually exist (in case your list of file names contains outdated information like files that have been moved or renamed). You can use Dynamo's built-in File.Exists
and Directory.Exists
nodes for that.
The next step is creating the journal files that we will need for running the batch process. The DynamoAutomation package contains the Journal.ByWorkspacePath
node that will take care of this for us. The node has three inputs:
-
revitFilePath
takes the list of Revit model paths we acquired in the previous step -
workspacePath
points to the slave graph (see chapters Master and Slave and Slave Graphs) we want to run on the models -
journalFilePath
specifies the name and path of each journal file that is to be generated. The journal files need to be written to Revit's addins directory. You can use theRevitAddinsPath.ByVersion
node included in the package to retrieve the default addins path for your particular version of Revit. -
revitVersion
specifies the version of Revit to be used (because journal contents will differ between pre-2017 and post-2016 Revit) -
debugMode
allows to run Revit in Permissive Journal Mode. That means that any errors or warnings that are encountered when opening the file or executing journal commands are ignored as best as possible. Set this input to true if you're processing models that are likely to produce warnings on being openend (e.g. missing links etc.).
The resulting journal files contain the following commands:
- Open the specified model
- Launch the Dynamo addin headless
- Load the specified slave graph
- Run the graph
- Quit Revit
Having created all necessary journal files we can now start the actual batch process. The Process.ByPathAndArguments
node included in the package launches and executes an external application – in our case we use it to launch Revit, but it could be any Windows *.exe file. When launched, many applications accept certain arguments that tell them what to do on startup. In our case the argument we want to pass to Revit is the path of the journal file so that Revit directly executes all the commands contained in that journal file. Supplying an entire list of journal file paths will result in Dynamo starting one Revit session after another until all journal files have been processed. For your convenience you can use the RevitExecutablePath.ByVersion
node included in the package to retrieve the path to your Revit.exe file.
Dynamo will need to create the journal files within your addins directory. Additionally, each Revit session that is launched using Dynamo sandbox will also create a journal file within that directory. Obviously we want to keep the addins folder clean which is why we should let Dynamo clean up after itself. Use the node JournalFiles.Cleanup
included in the package to have Dynamo move all journal files to a specified directory after the batch processing is done.