Looping inside grasshopper

Is there a way in grasshopper that we can loop through a set of operation…But with unique value at each iteration

for example- I want to loop the function “ADD”
and number of times to loop could be a number slide or variable input - (let’s say 4)
start data is - lets say 0
Now I want the program to ask user each time the number to be added

So function I want to achieve looks like (in Python) -

sum = 0
while x > 4 :
y = raw_input(“next number to add”)
sum = sum + y
x = x -1
print sum

Using plugins like Anemone or hoopsnake only allows me to do

sum = 0
while x > 4 :
y = 4 //Some constant transformation
sum = sum + y
x = x -1
print sum

So, this was just a simplified example…
The operations inside the loop could be move/rotate/or something complex
But for every iteration I want the user to decide the value for move/rotate than a constant

Okay I actually found a way around via Anemone
I made a list with all different values
Connected List Item component’s “i” to the counter in Anemone
So for each iteration it operates on the i’th item in the list!
Still not fully parametric as we have to make sure that number of iterations and total value in the list are same,
But does the job


Looping.gh (16.2 KB)

1 Like

There are lots of components that do the looping parts internally, I’m sure you’re aware of MassAddition but there might be a component for the task you’re trying to do with Anemone.


MassAddition.gh (12.8 KB)

Thanks a lot!
Solves the problem.

You could also use the GHPython scripting component (Math > Script).