Create a loop with help of Python or any other


I am very beginner in use of Dynamo and Python. Would you please help me to build a script, which is going to read 6 variables from previous Nodes. If test RH>MaxRH is true, then a recalculation of RH is required. Please see the image, I would really appreciate any help. Thank you.



I would highlight that what you are doing is design script and not python. If you was after python you need to look for a node called “Python Script” or similar.

There is some basic examples of python code on this github page that may help guide you on python.

1 Like

This is how you can write while loop in Design script.


Sorry, I do not understand this. Do you mind to explained it a little bit more?

As you see, in your design script code block you are missing return = [imperative] also you are missing your loop (while/for) etc. my post was just an example of design script sintax for codeblock loop.

Hi @ml31, I think what Jan and Brendan point out is that your node fails because the syntaxe is a mix between Designscript (working for code blocks) and Python (working in Python node).

For exemple your first IF statement is written without parenthesis as in Python, the second IF has parenthesis like in Designscript.

Find out on the net the correct DS syntaxe, correct it and you will make it work in the code block.

Also, I am no expert as I am learning it, but python is more efficient for this if you want to use a Python node (because DS uses a lot of parenthesis, semicolons, brackets as you can see in Jan’s Pic.

All the best