Foreach number loop runs only once!

   2001   2   1
User Avatar
Member
10 posts
Joined: July 2019
Offline
Hi,

Can anyone explain how the “Foreach Number” block works? Basic reasoning would suggest that everything inside the loop runs for “iterations” number of times.

But from this simple example that I'm attaching, it doesn't matter what number of iterations I set. The foreach loop only runs once (as shown by the printf in the wrangle node).

If anyone could shed some light on how this node block works it would be really helpful.

Thanks,
Bleeck.

Attachments:
foreach number.hipnc (74.4 KB)

User Avatar
Member
9384 posts
Joined: July 2007
Online
it's gonna be executed as many times as iterations parameter says and you can see that the number of polygons on the output geometry is changing with that parameter since you are merging all the iteration

the only difference is that your attribwrangle1 doesn't need to cook multiple times since it's not changing per iteration, so it cooks it once and then just merges the same cooked result each iteration

to see it print each iteration you have to force it to recook
for example connect foreach_count1 output to second input of your wrangle and chenge your code to
int i = detail(1, "iteration");
printf("zz %s\n", i);
Edited by tamte - Feb. 29, 2020 00:52:15
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
10 posts
Joined: July 2019
Offline
Thanks a lot. I didn't realize node cooking was a thing (I'm still just a couple of weeks into houdini). This explains a lot of things.
  • Quick Links