Skip to content

Dynamo Command Line Interface

Michael Kirschner edited this page Aug 14, 2015 · 2 revisions
  -o, -O=VALUE               OpenFilePath, Instruct Dynamo to open headless
                           and run a dyn file at this path

  -c, -C=VALUE               CommandFilePath, Instruct Dynamo to open a
                           commandfile and run the commands it contains at
                           this path,this option is only supported when run
                           from DynamoSandbox

  -l, -L=VALUE               Running Dynamo under a different locale
                           setting

  -p, -P=VALUE               PresetFile, Instruct Dynamo to import the
                           presets at this path into the opened .dyn

  -s, -S=VALUE               PresetStateID, Instruct Dynamo to set the graph
                           to the specified preset by name,this can be set
                           to a statename or 'all', which will evaluate all
                           states in the .dyn

  -v, -V=VALUE               Verbose, Instruct Dynamo to output all
                           evalautions it performs to an xml file at this
                           path

  -h, -H, --help             Get some help

####What The Command Line Interface (DynamoCLI) is a supplement to DynamoSandbox. it is a dos/terminal command line utility designed to provide the convenience of command line arguments to run Dynamo. In its first implementation it does not run standalone, it must be run from the folder where the Dynamo binaries reside, as it depends on the same core DLLs as the Sandbox. It can not interoperate with other builds of Dynamo.

There are four ways to run CLI: from a Dos prompt, from Dos batch files, and as a Windows desktop shortcut whose path is modified to include the specified command line flags. The Dos filespec can be fully qualified or relative, and mapped drives and url syntax is supported as well. It can also be built with Mono and run on linux or mac from the terminal.

Dynamo packages are supported by the utility, however you can not load custom nodes (dyf) only standalone graphs (dyn).

In preliminary testing the CLI utility supports localized versions of Windows and you can specify filespec arguments with upper Ascii characters.

The CLI can be accessed through the DynamoCLI.exe application. This application lets a user or another application interact with the Dynamo evaluation model by invoking DynamoCLI.exe with a command string. This might look something like:

C:\program files\Dynamo 0.8\DynamoCLI.exe -o "C:\someReallyCoolDynamoFile.Dyn"

This command will tell Dynamo to open the specificed file at "C:\someReallyCoolDynamoFile.Dyn", without drawing any UI, and then run it. Dynamo will then exit when the graph has completed running.

####Important Notes

  • The preferred method of interacting with DynamoCLI is through a command prompt interface.
  • At this time you will need to run DynamoCLI from its install location inside the Dynamo.8 folder. The CLI needs access to the same .dlls as Dynamo so it should not be moved.
  • You should be able to execute graphs that are currently open in Dynamo, but this may cause unintended side effects.
  • All file paths are fully dos compliant so relative and fully qualified paths should work, but be sure to enclose your paths in quotes "C:path\to\file.dyn"
  • DynamoCLI is new functionality and currently in flux: the CLI loads only a subset of standard Dynamo libraries at this time, note this if a graph does not execute correctly. These libraries are specified here
  • currently no std output is provided if no errors are encountered, the CLI will simply exit after the run completes.

####Why You might want to control Dynamo from the command line for various reasons, these might include:

  • Automating many Dynamo runs
  • Testing of Dynamo Graphs (also look at -c when using DynamoSandbox)
  • Running a sequence of Dynamo graphs in a specific order
  • Writing batch files that run multiple command line executions
  • Writing another program to control and automate the running of Dynamo graphs and do cool things with the results of those computations

####How

-o /o you can open dynamo pointing to a .dyn, in a headless mode that will run the graph.

C:\program files\Dynamo 0.8\DynamoCLI.exe -o "C:\someReallyCoolDynamoFile.Dyn"

-p /p can point to a “presets file” or another .dyn that has an presets in it, this will append states from the specified presets source file to the opened destination file so many states do not need to be stored in the original .dyn.

    C:\program files\Dynamo 0.8\DynamoCLI.exe -o "C:\someReallyCoolDynamoFile.Dyn" /p "C:\aFileWithPresetsInIt.dyn"

In the example above someReallyCoolDynamoFile.Dyn is the destination file, as this is the file we have instructed the CLI to open. aFileWithPresetsInIt.dyn is the source file, which we are extracting presets out of. We then import these presets into the destination file.

A presets file is an xml file with nothing in it but a presets element, it might look something like this:

<Workspace Version="0.8.2.1605" X="0" Y="0" zoom="1" Name="Home" RunType="Automatic" RunPeriod="1000" HasRunWithoutCrash="True">
<Presets>
    <PresetModel Name="state1" Description="10" guid="be5146ea-806e-42a2-be42-45130b9c8ec0">
      <Dynamo.Nodes.CodeBlockNodeModel guid="2ef55ca9-1342-43d5-b5e1-44abb09fb2f5" type="Dynamo.Nodes.CodeBlockNodeModel" nickname="Code Block" x="216.146596858639" y="69.8848167539266" isVisible="true" isUpstreamVisible="true" lacing="Disabled" CodeText="5;" ShouldFocus="false" />
      <Dynamo.Nodes.DoubleInput guid="c67de4ff-96ab-4386-94ba-5a680688e8f8" type="Dynamo.Nodes.DoubleInput" nickname="Number" x="216.523560209424" y="242.659685863874" isVisible="true" isUpstreamVisible="true" lacing="Disabled">
        <System.Double value="2" />
      </Dynamo.Nodes.DoubleInput>
      <DSCoreNodesUI.Input.DoubleSlider guid="aeb94820-ee65-428c-932c-929948eb680b" type="DSCoreNodesUI.Input.DoubleSlider" nickname="Number Slider" x="51.6649214659685" y="358.261780104712" isVisible="true" isUpstreamVisible="true" lacing="Disabled">
        <System.Double>0</System.Double>
        <Range min="0" max="100" step="0.1" />
      </DSCoreNodesUI.Input.DoubleSlider>
    </PresetModel>
    <PresetModel Name="state2" Description="31" guid="1190406a-ef14-4963-9c53-cba5518da8ac">
      <Dynamo.Nodes.CodeBlockNodeModel guid="2ef55ca9-1342-43d5-b5e1-44abb09fb2f5" type="Dynamo.Nodes.CodeBlockNodeModel" nickname="Code Block" x="216.146596858639" y="69.8848167539266" isVisible="true" isUpstreamVisible="true" lacing="Disabled" CodeText="6;" ShouldFocus="false" />
      <Dynamo.Nodes.DoubleInput guid="c67de4ff-96ab-4386-94ba-5a680688e8f8" type="Dynamo.Nodes.DoubleInput" nickname="Number" x="216.523560209424" y="242.659685863874" isVisible="true" isUpstreamVisible="true" lacing="Disabled">
        <System.Double value="1" />
      </Dynamo.Nodes.DoubleInput>
      <DSCoreNodesUI.Input.DoubleSlider guid="aeb94820-ee65-428c-932c-929948eb680b" type="DSCoreNodesUI.Input.DoubleSlider" nickname="Number Slider" x="51.6649214659685" y="358.261780104712" isVisible="true" isUpstreamVisible="true" lacing="Disabled">
        <System.Double>25</System.Double>
        <Range min="0" max="100" step="0.1" />
      </DSCoreNodesUI.Input.DoubleSlider>
    </PresetModel>
    <PresetModel Name="state3" Description="20" guid="f3f9fe5e-a203-4db7-860a-44f445397740">
      <Dynamo.Nodes.CodeBlockNodeModel guid="2ef55ca9-1342-43d5-b5e1-44abb09fb2f5" type="Dynamo.Nodes.CodeBlockNodeModel" nickname="Code Block" x="216.146596858639" y="69.8848167539266" isVisible="true" isUpstreamVisible="true" lacing="Disabled" CodeText="0.5;" ShouldFocus="false" />
      <Dynamo.Nodes.DoubleInput guid="c67de4ff-96ab-4386-94ba-5a680688e8f8" type="Dynamo.Nodes.DoubleInput" nickname="Number" x="216.523560209424" y="242.659685863874" isVisible="true" isUpstreamVisible="true" lacing="Disabled">
        <System.Double value="0" />
      </Dynamo.Nodes.DoubleInput>
      <DSCoreNodesUI.Input.DoubleSlider guid="aeb94820-ee65-428c-932c-929948eb680b" type="DSCoreNodesUI.Input.DoubleSlider" nickname="Number Slider" x="51.6649214659685" y="358.261780104712" isVisible="true" isUpstreamVisible="true" lacing="Disabled">
        <System.Double>20</System.Double>
        <Range min="0" max="20" step="0.1" />
      </DSCoreNodesUI.Input.DoubleSlider>
    </PresetModel>
  </Presets>
</Workspace>

This presets file or another .dyn with presets embedded is considered the source, the presetModels here will be imported into the destination file, the file we instructed Dynamo to open with -o.

-s /s can either be set to the preset name or “all”, this will cause dynamo to iterate through all the currently loaded presets, and then run the graph for each preset.

 C:\program files\Dynamo 0.8\DynamoCLI.exe -o "C:\someReallyCoolDynamoFile.Dyn" /p "C:\aFileWithPresetsInIt.dyn" /s "state1"
 
or
 
      C:\program files\Dynamo 0.8\DynamoCLI.exe -o "C:\someReallyCoolDynamoFile.Dyn" /p "C:\aFileWithPresetsInIt.dyn" /s "all"

-v /v can be used when Dynamo is running in a headless mode (when we have used -o to open a file), this flag will iterate all nodes in the graph and dump their output values to a simple xml file. Because the /s flag can force Dynamo to run multiple graph evaluations, the output file will hold values for each evaluation that occurs.

    C:\program files\Dynamo 0.8\DynamoCLI.exe -o "C:\someReallyCoolDynamoFile.Dyn" /p "C:\aFileWithPresetsInIt.dyn" /s "all" /v "C:\output.xml"

The xml output file would have the form:

    <evaluations>
        <evaluation0>
            <Node guid="e2a6a828-19cb-40ab-b36c-cde2ebab1ed3">
                <output0 value="str" />
            </Node>
            <Node guid="67139026-e3a5-445c-8ba5-8a28be5d1be0">
                <output0 value="C:\Users\Dale\state1.txt" />
            </Node>
            <Node guid="579ebcb8-dc60-4faa-8fd0-cb361443ed94">
                <output0 value="null" />
            </Node>
        </evaluation0>
        <evaluation1>
            <Node guid="e2a6a828-19cb-40ab-b36c-cde2ebab1ed3">
                <output0 value="str" />
            </Node>
            <Node guid="67139026-e3a5-445c-8ba5-8a28be5d1be0">
                <output0 value="C:\Users\Dale\state2.txt" />
            </Node>
            <Node guid="579ebcb8-dc60-4faa-8fd0-cb361443ed94">
                <output0 value="null" />
            </Node>
        </evaluation1>
    </evaluations>

You can use this file to lookup a node's output values by its ID. For example, in the above output file, we can see that one node has changed its value from "C:\Users\Dale\state1.txt" to "C:\Users\Dale\state2.txt".

-h /h use this to get a list of the possible options

C:\program files\Dynamo 0.8\DynamoCLI.exe -h
Clone this wiki locally