Looking for an object to do a loop


(Joe Babb) #1

I’d like to do a loop like for(i=0;i=10;i++);
Is there a component to do that?
I was looking at http://rhino.github.io/components/anemone/loopInput.html and found something called Anemone, but I don’t think I have that in Grasshopper or at least I can’t find it.

(Laurent Delrieu) #2

Most of plugins are on Foo4Rhino


If you’re new to Grasshopper lists and used to loops in other languages, you might be surprised at what can be done “the Grasshopper way”, without loops. What do you want to do?

(Joe Babb) #4

I am new to GH and I’m used to languages like C++. How can you live without loops? Suppose I wanted to loop through a list of values and decide to jump out of the loop if a value exceeded a threshold? Just pulling that out of the air. I’d like to see examples of the “grasshopper way”.

(Michael Pryor) #5

In grasshopper the logic is more like make all the data then select/remove from it. Or make all data within a limit.


Cull and Dispatch use the same filter pattern:

no_loop.gh (9.9 KB)


spider.gh (12.7 KB)

(Joe Babb) #8

Thanks. I really appreciate both these examples. I have two questions about spider. The EvalSrf shows as “old”. What replaces it? The dashed lines have me curious. I’ve had some difficulty selecting the wire display never being sure of where to click to bring it up. Why did you make these lines dashed?
Thanks again. I learn a lot from examples.


I don’t know what happened to EvalSrf in Rhino 6?

As to the dashed lines, they indicate multiple branches in the data tree. I didn’t do anything, that’s the default behavior. So you can tell by looking at the wire if it’s a single item (one line), a list of items (double lines) or a tree with multiple branches (lists), the double dashed lines.

The ‘Maths | Script | EValuate’ component is another way to run a function on every item in a data tree, which can produce similar filtering effects.


boxes.gh (18.1 KB)

It’s not that I have anything against loops - I love Anemone. It’s just that Grasshopper has ways to do some things that don’t require loops. It effectively iterates through all items in a data tree (numbers, geometry, text or whatever), culling, dispatching, manipulating the data tree to make a new copy. The ‘Pr’ (Partial Results) output of MA (Mass Addition) is a subtle, different kind of example of this “touch all” way of thinking.

Random box, Iterative processq
(Michael Pryor) #11

I don’t know what happened to EvalSrf in Rhino 6?

It just has extra U,V outputs.