Is there a way to loop using geometry nodes?

I’ve created a node network and got it to the point where I’ve encapsulated each node into a group. Now I’d like to create a node that lets the user select the number of times this node is applied. You can see in the graphic that I’ve chained six of these together. Is there a way to create an integer input and then just have that many copies of my group operate in a row? Or even just have it mute some of the nodes (eg, if the user picks 2 iterations, have that mute the 3rd through 6th links in my chain here)?

Hi,

One way is to use a switch geo node with the switch driven by frame.

Hope that helps

1 Like

I did the same, there is no loop function so far.

Softimage ICE had a repeat node that was great. I hope we get one soon.

What you describe is possible using the Switch node.

e.g. Here just doing 1 iteration:


With Node-Group:

Another option is to use the Simulation nodes… running the sim for the amount of frames that match your desired iterations.

Good luck.

I hardly understand that as a solution… is it about using a simulation node and computing it at each frame?

seems like overkill given the initial question

Did I mention Simulation nodes? or are you replying to @zeroskilz ?

I kinda agree with SGarnier… I also don’t understand how your answer was marked as a solution.

The initial question was about loops or controlling iterations and yours just replaces the geometry on a certain frame. :man_shrugging:

Asking if it is part of a feedback/sim-loop is a fair question.

Given that Blender does not provide loops or anything similar, I figure this is about as close as I can get. At least I can use an integer to set the number of iterations. While I would like to have true looping, this will have to do for now. (Actually, I’d like to have geometry nodes completely replaced with a programming language. This is not a pleasant system to work in.)

There are a couple of loop proposals on the devtalk site but for the majority of things that people think you need loops for you can actually get away with a combination of the Duplicate Elements node and Accumulate Field node… - there is also a lot you can do with Simulation Nodes that give the same result as a loop node would (but at the cost of a true non-destructive solution).

Hopefully we’ll get loops in 4.x sometime.

Python script support has been part of Blender for a long time. You may want to have a look at some tutorials on how to use it. Also expecting to get an Expression node at some point which will make the math-spaghetti more manageable.
But in principle I agree - visual scripting generally can’t beat the expressive power of symbolic languages, but even so, for some SIMD-style problems GN does a really great job at what would be painful to pull of with a programming language… you just need to get used to the fact that GN isn’t a programming language and doesn’t try to be.

Good luck.

I’ve used Python in Blender before - unfortunately, there does not seem to be a way to create a node with non-destructive tweakable parameters. I’d really like to see an expression node with a GLSL-like language optimized for geometry operations.

Well, Python Nodes aren’t really a thing but controls have an update function so you can code something that re-evaluates the construction upon a control update… the performance just won’t be as good as what you’d be able to do with GN.

How would you do that? For addons, I thought you could only edit your operator’s parameters during their initialization phase? They just turn into a regular mesh after that.

No, neither do I,

It was early, just before breakfast and I meant to show some node groups switching on a user input as I was under the impression the OP had understood there was no loops.

Then the Oven pinged me

Breakfast was lovely,

…and then that happened!

Yeah I cant wait for loops either!

2 Likes

Use the update callback. You’ll have to keep a reference to your generated object, then in the callback function, delete it and start again.

Good luck!