4
$\begingroup$

In houdini it is posslible to create a for loop to repeat functions easily, is this possible in geometry nodes? the setup below is my current solution,its extremely messy and not very scalable has anyone found a better solution to this problem?

enter image description here

$\endgroup$
2
  • 2
    $\begingroup$ can you describe what you want to do inside the loop (pseudocode). in some cases it is possible to construct a node group such that combining them linearly in a chain, will also give the same result $\endgroup$ Commented May 25, 2022 at 16:13
  • $\begingroup$ @ShantanuAryan since Blender 4.0 there are loops in Blender - it's called a "Repeat Zone". It doesn't allow you to break early, and you can't loop indefinitely - so you need to know in advance how many iterations you want the loop to have. You can work around it by nesting the repeat zones to support a lot of iterations without significant overhead once you reach the final state - so you don't break still, but the outer repeat zone uses a switch to not use any inner repeat zones anymore. $\endgroup$ Commented Jun 11 at 9:33

1 Answer 1

7
$\begingroup$

It is not possible to create loops in Geometry Nodes. There is a better solution for many problems that uses an Instance on Points node to create the duplication. Here is a rough example:

Instances on points node idiom

The mesh line is used to generate a number of points, its Count value. It can also be modified by a Set Position node to control the locations. Many other nodes or node groups can substitute depending on your need.

The key is the Instance input to the Instance on Points node. Not shown in this picture, whatever feeds it is the geometry you want to repeat. That's usually replaced by whatever geometry you want to repeat.

There are similar approaches for other looping-like constructs. They rely on the fact that 3.x Geometry Nodes uses Fields and you can set up the contents of a field as if it were your loop variable and then modify it with nodes like Instance on Points

$\endgroup$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .