For Loop in For Loop bug?

   3148   5   2
User Avatar
Member
14 posts
Joined: Nov. 2013
Offline
I have a for loop nested inside another for loop. In this child for loop I have some logic that needs to know what iteration I'm currently through the parent for loop.

However returning ( “../../each1/attribval1” ) is returning the same number as ( “../each1/attribval1” ) which breaks my scene.

I've created a simple example of this ‘bug’ occuring in the ForEach.hip

To get a better context of what I'm doing, take a look at BuildingGenerator2.hip
Maybe what I'm trying to do is an illogical way of going about it, so if anyone could point me in the direction of a solution it'd be much appreciated!

Thanks.

Attachments:
BuildingGenerator2.hip (197.3 KB)
ForEach.hip (79.6 KB)

User Avatar
Member
678 posts
Joined: July 2005
Offline
Simple example of the problem
I have not seen your scene but probably simple answer for the problem is in first help TIP
http://www.sidefx.com/docs/houdini13.0/nodes/sop/foreach [sidefx.com]
User Avatar
Member
228 posts
Joined: Dec. 2012
Offline
Yes - to confirm, I opened up your file and both of your loops are using “FORVALUE” and “FORIDXVALUE”, so they will be overwriting each other's iterators. You will want to change both stamp names on at least one of the loops (I usually just tag a little identifier on the end). Not sure if there are other bugs in your scene, but that is definitely one.
www.kmcnamara.com
User Avatar
Member
14 posts
Joined: Nov. 2013
Offline
Ah, thanks so much! Can't believe it's such a simple fix, I will look out for that from now on.
User Avatar
Member
1743 posts
Joined: March 2012
Offline
Yeah, this is an awful bug with ForEach. I ran into it myself a couple weeks ago and spent hours trying to figure out why things were recooking in a completely bonkers order and with nonsense output. It'd be really nice if the scoping on the stamp variables was respected, but apparently it has to be broken for some esoteric reason that I don't know if I really trust.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
4523 posts
Joined: Feb. 2012
Offline
ndickson
Yeah, this is an awful bug with ForEach. I ran into it myself a couple weeks ago and spent hours trying to figure out why things were recooking in a completely bonkers order and with nonsense output. It'd be really nice if the scoping on the stamp variables was respected, but apparently it has to be broken for some esoteric reason that I don't know if I really trust.

I too spent a few hours on this bug years ago, and was surprised no one complained about it before. I suggested a potential solution in the other thread
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
  • Quick Links