Is there a way in the repeat zone in geometry nodes to access the current iteration? I'm wanting to essentially create lines between points on two different curves via their indices, i.e. a line between point 0 on line 1 and point 0 on line two, with a line for each pair of points on each line. Programmatically, if this were run like a for loop, I'd just use the current value of the iterator as the index of the points. I know I could do it manually for each point and was hoping a repeat zone would get around that.
-
2$\begingroup$ unfortunately - no. Just create a new input (integer), add an add +1 node and connect that between in- and output of the repeat zone. Name it: current iteration ;) $\endgroup$– ChrisCommented Nov 9, 2023 at 16:08
-
3$\begingroup$ and i am missing that too...! $\endgroup$– ChrisCommented Nov 9, 2023 at 16:08
-
2$\begingroup$ After fiddling a bit, I got most of the way there, except I hadn't thought to connect the value I was adding to into the output, so thanks for that last step! $\endgroup$– Christopher RescorlaCommented Nov 10, 2023 at 17:25
2 Answers
First you'll want a counter. Note that count starts at zero, adds 1 in the repeat zone, then feeds back into count.
Next, you'll want two curves, and resample them to the same amount of iterations you want. A big trip-up with the repeat zone seems to be what happens inside vs. outside the repeat zone; at first this didn't work for me because I was using Geometry inputs named Curve1 and Curve2 and it wouldn't work.
Next, I sample index of each curve at the index of the count, sampling the position. I use that value for the start and end of a curve line. That's joined to the geometry. Here's the final result:
An Iteration index socket (integer output) was added to the Repeat Zone node in Blender 4.3.
Iteration Index of the current iteration. Starts counting at zero