How to create Loop in dynamo

Hello Dears,

I have a dynamo script which is applicable on selected element by (select model element.node), and the number of element I should select is large, so i need to solve this problem and select all elements in the same time by ( select model elements.node) and make the scripty run individually on the all element, i need the script make the all prcess for the first element and end then start again with the second element.

Please can you help me how to get this.
Thank you so much

We’ll need more details, but typically you don’t need to build an actual loop for handling multiple objects. Dynamo naturally iterates over lists and treats each item as a unique input based on list structure and node input types.

For more complex graphs, this just means using list manipulation and specific data structures (along with list levels in many cases) to force Dynamo to use the input structure you want.

3 Likes




As shown in the scripts is done for only selected one element, but i need to replace the node to select multiple nodes and make the whole script to loop for every element not to edit the script and modify levels and interact with the levels.

Thank you sir for replying, I know how to deal with the lists and level, but i dont want to edit the script, all i need to add loop tos do the same logic for all the elements that i select individually instead of select element one by one

You have two options.

  1. As @Nick_Boyts mentioned, edit the graph to enable select model elements instead of select model element. This won’t take long and if you know list lacing and levels it should be fairly easy. I typically write most of my ‘not sure how to manage this just yet’ graphs for a single instance, then a set of 3 instances, then the full scope.

  2. Convert all of your nodes excepting the ‘input’ into a custom node, and use that instead of all the nodes. The Dynamo primer has a good example on how to do this: Custom Nodes | English | Dynamo. Note that this means you’ll need to deploy that custom node to everyone who wants to use the graph, and you’ll need to maintain it and any custom nodes which it maintains in future versions of Dynamo.

1 Like