How to run a Dynamo Graph in the background / How to use the Dynamo Command Line Interface

Hi everyone,

I often use the Dynamo Sandbox environment because then I don’t have to open a host application, which saves time and resources. One disadvantage I always had with this was that I couldn’t run scripts without having to open my Dynamo Graphs itself, like the Dynamo Player.

In my quest to reduce my number of clicks, effort & time, I came across a very handy feature of Dynamo that many people probably do not (yet) know. At least I didn’t! :smiley: :

The Dynamo Command Line Interface

The Dynamo Command Line Interface (DCLI) is a functionality of Dynamo which opens a broad way of possibilities to easily run Dynamo scripts, and even run them in Batch, without having to open Dynamo itself.

For Example:
I have created a script which creates .scr-files such that the End User doesn’t have to rewrite the code everytime, (and they probably also don’t know how :slight_smile: ). Before the only way to run this script was to open the Dynamo Player, open the entire script and press “Run”.

When we use the DCLI workflow, all I have to do is run a .bat file that is on my desktop and the script runs itself!

How to create this .bat-file?:
For this .bat file, we actually only need three components:

  1. The location of the DynamoWPFCLI.exe (found in the same folder as the DynamoPlayer.exe.
  2. The command “-o”, this will open Dynamo in a headless variant (see the GitHub like for a more indepth explanation).
  3. The location of the Dynamo file to be executed (between double quotes: ").

When you have done this correctly, it should look something like this (one line):
C:\Users%USERNAME%\Downloads\DynamoCoreRuntime2.10.1\DynamoWPFCLI.exe -o “F:\Dynamo\Dynamo Onderzoek 4 - Multiple DWG Interaction\07. AutoLISP insteek\Dynamo Scripts V2.0\LISP scr Creator V0.2.dyn”

Save your command line to a .txt-file and rename this to a .bat-file and you’re done! :smiley:

Result:
When you now double click this .bat-file it automatically opens the Windows Command Prompt and runs the Dynamo Graph in the background. I also tested this workflow on a Graph which contains Data-Shapes nodes and they also seem to be working properly:

Further reading:
For further reading into the functionalities I highly recommend checking out this GitHub page.

19 Likes

Wow - The potential applications of use for this are a little overwhelming to consider!

Definitely going to be testing this one out.

Thanks for showcasing this functionality!

3 Likes

This is pretty awesome, @Daan. I wasn’t aware of it. Have you tried using this with Revit scripts? I assume it would still be able to open Revit in the background for any script that has a specified document input?

I think @Andreas_Dieckmann shown us a lot more back in 2015??
He showed how to use this with Windows Scheduler (to run the .bat at certain times).
He also created the Dynamo Automation workflows.

3 Likes

I have not tested this method with Host Applications in mind, but that, together with running multiple scripts in batch is the next step.

I’ll keep you updated in this topic

1 Like

Small update:

To batch run multiple Dynamo Graphs consecutive you’ll just have to add a new line into the .bat-file. With this setup the .bat-file opens your first Dynamo file and executes it completely, closes Dynamo and restarts the process.

PS: Does anyone know where the Dynamo.exe is located for Civil3D and Revit? Would like to do some testing on this method with Dynamo Versions which depend on Host Applications.

Don’t believe there is one. Didn’t think of that. :man_facepalming:

I believe it is at the below location for Civil 3D. However, I don’t think launching it this way will do so within the context of AutoCAD/Civil 3D.
C:\Program Files\Autodesk\AutoCAD <version>\C3D\Dynamo\Core

The AcDynamo.dll located below is what makes Dynamo available for launch within Civil 3D:
C:\Program Files\Autodesk\AutoCAD <version>\C3D\Dynamo

1 Like

Is this function similar to “AECCRUNDYNAMOSCRIPT” that I use for run Dynamo in Civil 3D without opening the Dynamo Core or Dynamo Player? I have created .scr files that run the actual Dynamo script so the user don’t need to open Core or Player to run the Dynamo script. We also can use the function to run Dynamo scripts on Vault Job Processor but if we can use bat-file instead it would open another option as well.