Calculate the same formula for different values from python

Hello everyone, I apologize for my inexperience with Python. I can’t understand why the script works very well with a single number, but it can’t apply the same formula for different values. I would like that starting from different values. Thank you all for the support.


Dynamo handles lists by opening them up and iterating over them. This is what the joys of lacing and associative code bring to the visual programming and design script world.

Most other languages will not do this; they are imperative languages and as such it is imperative (couldn’t help myself) that you inform the system how you want it to deal with lists.

As such you will need to do one of two things.

  1. Convert your Python info a node by making it into a custom node. This will give you full lacing control.
  2. Edit your Python code to handle the list input by adding the relevant for or while loop(s) to your code.

You can learn about #1 in the Dynamo Primer, and #2 in a multitude of Python resources online. We can’t help with either unless you provide the actual code though.

1 Like

prova 5.dyn (8.1 KB)

@jacob.small Thank you for your advice but unfortunately even converting my node I was not able to.

You likely didn’t edit the custom node’s inputs, which may not have been clear the first time out because all of your data was coming from one source Dynamo assumed you would want to reuse the same input.

This is how I would accomplish the Python option, with a few extra screen grabs to illustrate the limitation of all inputs being a list of matching depth:



And this is the result of a properly configured custom node:


What the custom node’s setup should look like:

Note you should name the inputs something more useful than “input0’, something which a user understands upon placing the node (ie: “BendingResistance”) and likely provide a full summary of the intended input value by putting a comment in the input node like this \\Detailed description about what this input is for after the var or on a subsequent line of code.

2 Likes