Running Dynamo through command line with inputs and outputs

Is it possible to run dynamo file through command line by assigning input values for certain nodes and retrieving output values from certain nodes, similarly how in generative design add-on you can set nodes to input and output.

So far I only found running dynamo in command line, but without possibility to assign input values, and for the output you get the values for all of the nodes, which is quite excessive.

The intent is to run dynamo in batch to check smaller set of design alternatives using a list of input values to get the output values, which the generative design tool does not support.

What about using an Excel or CSV-file? You could read and write to that file for every run.

Problem would be that you would need to loop the dynamo script so it would go over each row in csv file, I think there exist some plugins for that, but it would require adjusting the code, which I would prefer not to do.

Can you explain, in detail, what you’re specifically trying to accomplish here and how Dynamo GD can’t handle the inputs? There might be a workaround with some clever thinking.

I’ve been working on finding a set of possible solutions with ML models through data generated with generative design, now I need to verify the solutions with the dynamo script. This requires manually setting the input values to the slider nodes and then waiting for the outputs. I would like to use GD add-on to verify this set of solution, but currently it has no such mode to add a set of inputs to analyze, so I’ve been looking into the possibility of automating it somehow through command line.

Problem is that I have a large dynamo script that it takes 20~30s on the first run, but when running it subsequently it takes few minutes for the same script to execute (either through TuneUp Force Re-execute or by running it again in Dynamo. This is the only thread that I’ve found on this problem: Second run of Dynamo is taking a long time , but it has no solution).

I am not sure how GD executes dynamo script in batches in the background using inputs and outputs, but if there is any information on how to replicate that I would welcome it. (I did not find any source code for Project Refinery)

Hi @luka.g ,

Why do you want to use the Generative Design “package” if you already know your initial values?
Couldn’t you use your values as a list input to get a list output?

Oversimplified example:

This was going to be my first suggestion. Modify your graph a little bit (if necessary) to compute all your designs at once. You could even generate scores or visual indicators based on performance metrics.

You could also use these designs as a list of inputs for GD to select instead of trying to make GD generate all the individual inputs again. Depending on how many solutions you have to recreate, you could either use Cross-Product (forget what it’s called now) or Random. The problem with Random of course being that you couldn’t guarantee all the solutions get created. This is why I think the first suggestion is better.

I am well aware about working with lists, but my whole code was set up to work with generative design and changing it to work with list of inputs would take way too much time as I am working with a complex script with 1000+ nodes.

Yes, I see second suggestion working, thank you for that. But I would still be interested in possibility of doing it as posed by my first question.

What about using a simple text file which keeps track of the database input indice it should loop through? Then you could just do N+1 to keep looping through the script with other inputs.

Then you would only have to copy paste (or automatically generate) a windows batch file with the amount of loops you want to run copied into it.

–

Also, what does your script to that you need 1000+ nodes?!

Could you clarify the looping part? Wouldn’t this require a special add-on to enable looping inside dynamo, or do you have something else in mind?

About the script - I have a parametric code to subdivide geometry to finite elements, produce correct naming schema and loading so I can run the structural analysis with Python in Dynamo, together with the visualization of the results from the analysis.

I mean something like this:

This, in combination with this (below), could make your worklfow automatic.

3 Likes

Thank you @Daan for taking your for the demonstration. With Force Run or TuneUp Force Execute the problem with re-runs taking much longer still persist. But I can see this working with the command line like you suggested, will have to test it.

Would be still interesting to know how it is done behind Generative Design/Project Refinery tool, I presume that GD uses also command line to run the scripts in the background so that leaves me wondering if this can be easily be replicated or is there something more complicated done to achieve that. It might be nice to create an automated script for my problem, without interfering with the script.

@nate.peters @craig.long any thoughts on how to help out @luka.g here with multiple run slowness?

I believe that Generative Design does this now by modifying the input values prior to sending the value; effectively the process is this:

  1. Set DYN to have the desired inputs;
  2. Send DYN to Dynamo headless;
  3. Get results back and add them to the GD results database;

If someone were to send this across my desk, and the hope was to run the combination of selected results in regular player to verify things, I think I’d collect all the results in a single CSV, with each input being a row, and the values being the series of inputs.

I’d then save the garph used for generation as a new graph, read that CSV into the file, split the rows, use a List.GetItemAtIndex node to pull out one row, and feed the values into the GD graph where the associated inputs were, and hit run. Check the results, and move to the next integer in the get item at index node.

As far as why your graph is slow on the second run… Best to start a thread with that and share the graph, along with any and all associated data. You may have some element binding weirdness happening, or it could be a memory issue, or something else; we’re not able to help without a graph though (just like the prior thread).

3 Likes