Skip to content
Andreas Dieckmann edited this page Aug 13, 2017 · 5 revisions

The samples section contains examples for all of the methods described below except the usage of the Windows Task Scheduler.

Custom Config Files

Creating and parsing your own configuration files is actually quite easy. It will help you minimise the number of inputs to a single input that reads a custom-made configuration file. Those config files can be simple text files that include attribute-value pairs, like so:

ModelDir=C:\temp\DynamoAutomation\revit_models\dir1
GraphPath=C:\temp\DynamoAutomation\slave_graphs\CountWalls_R2016_withConfig.dyn
RevitVersion=2016
OutputDir=C:\temp\DynamoAutomation\output
JournalFileName=DynamoJournalFile
ReportFileName=AutomatedReport
JournalOverwrite=1

Working with Presets

Presets were introduced with Dynamo 0.8.2. You can think of presets as something that is analogous to family types in Revit as they let you store different sets of default values for a group of nodes. To create a new preset, follow these simple steps:

  • Make sure that all your input nodes are laid out in such a way that it is easy to select them as a group.
  • Make sure that all your input nodes are set to the desired values.
  • Select all relevant input nodes.
  • Choose Edit > Presets > Create Preset From Selection (or simply press Ctrl + T).
  • Name your preset. When you open a Dynamo graph that contains presets you can bring up the values of a given preset by choosing Edit > Presets > Restore Preset > NAME_OF_YOUR_PRESET. It is currently not possible to edit a preset, but choosing Edit > Presets > Delete Preset > NAME_OF_YOUR_PRESET lets you delete a specified preset from the list of stored presets. There is also no way to preview the node values of a preset other than restoring that preset and examining the respective nodes.

DynamoAutomation includes three nodes that facilitate the batch-creation of presets:

  • Presets.ByWorkspacePathAndSliderNames: Creates Presets of all possible combinations of any given Integer Slider values within a Dynamo workspace and adds them to the original workspace file.
  • Presets.ByWorkspacePathSliderNamesAndNewPath: As above, except that it creates a new separate Preset file
  • Presets.Clear: Removes all Presets from a given workspace file.

Since this approach stores the data directly in the graph it may be considered superior to working with custom configuration files. In the end, it's probably a matter of taste and how you want to maintain your automation scenarios. Note that while you can use presets in both Dynamo Sandbox and the Revit addin, presets currently cannot be triggered in the Revit addin so you might want to use presets with master slaves and configuration files with slave scripts.

Please note that the three presets nodes currently are not working currently.

Running Dynamo Headless

The Dynamo CLI is Dynamo's command line interface and was also introduced in Dynamo 0.8.2. It allows you to run the Dynamo sandbox headless by supplying a number of arguments. You can find more information about it on the Dynamo wiki. With the provided samples you can test the following scenarios:

  • Open the DynamoCLI and run a graph: C:\Program Files\Dynamo 0.8\DynamoCLI.exe -o "C:\temp\DynamoAutomation\master_graphs\Scenario_A1.dyn"
  • Open the DynamoCLI and run a graph with a specified preset: C:\Program Files\Dynamo 0.8\DynamoCLI.exe -o "C:\temp\DynamoAutomation\master_graphs\Scenario_A1_withPresets.dyn" /s "dir1"
  • Open the DynamoCLI and run a graph with all its presets: C:\Program Files\Dynamo 0.8\DynamoCLI.exe -o "C:\temp\DynamoAutomation\master_graphs\Scenario_A1_withPresets.dyn" /s "all"

You can run these commands in a number of ways:

  • From a DOS prompt
  • As Windows desktop shortcuts
  • From DOS batch files (*.bat) (see chapter Using Windows Batch Files)

Combining the presets functionality with the CLI gives you the ability to run multiple versions of the same batch process scenario with minimal effort – just one line of text in a DOS prompt or a simple double-click on a Desktop shortcut.

Using Windows Batch Files

Batch File Model

From the Dynamo CLI it's just another tiny step to full automation. You can combine multiple calls to the Dynamo CLI in a DOS batch file. Creating batch files is really easy. You can use the provided sample file as a template. Open a text editor like Notepad.exe, copy/paste the contents of the example file into it and edit the calls to the Dynamo CLI according to your needs.

Using the Windows Task Scheduler

Task Scheduler Model

Using batch files is great if you want to combine a number of Dynamo batch processes in a single command that you can launch at your leisure. For recurring tasks it may, however, be more appropriate to make use of the capabilities of the Windows Task Scheduler. It allows you to schedule the launch of programs at pre-defined times. Combine that functionality with a batch file (or a simple call of the Dynamo CLI) and you can easily have Dynamo run all your batch processes during the night and come back the next morning to find that all the grunt work has already been taken care of.

To get you started, have a look at these tutorials on setting up tasks in the Windows Task Scheduler: