For Loop in Imperative Block

Why does this loop not work?
Are for loops only possible within functions?

Return n, not numbers


What you’re actually doing is looping 30 times.

1 Like

Is that the solution?

What is “number in numbers”? Is that 3 (listed) values or 31 values from [0] to [30]?

What is the desired output? Sure this is possible, but must admit my design script is not fantastic so would personally use Python nodes for loops as this :slight_smile:

I simply want to adress each item in a list [100,200,300] with the same operation, such as +100.

Later it should be used to calculate the distance between one point (point1) and each point in a list of points = [point1, point2, point3, …], so the result will be a list of distances.

No need to get imperative here, design script has functionality to iterate over lists this simple in much simplistic manor. Just use the addition function directly.


This will add 100 to every input.

If your math was more involved, the same thing applies:


The distance to question you had can be quickly set up by using the node to code functionality. Place a Geometry.DistanceTo node, wire it in with your points, select the node, right click the background and choose ‘node to code’ a s you’ll get the right solution for that as well.


So iteration over lists looks simple in DS.