accumulative for loop translate

   2918   6   0
User Avatar
Member
1104 posts
Joined: Aug. 2008
Offline
I thought by moving the box in this file with $ZMAX every loop it would end up beside each other but it becomes accumulative..not sure why.. in the end I was planing to switch between boxes with different sizes making them stack nicley no matter the size because the $ZMAX would always move the the correct distance.

clearly I am wrong

Attachments:
forloop.hipnc (51.2 KB)

/M

Personal Houdini test videos, http://vimeo.com/magnusl3d/ [vimeo.com]
User Avatar
Member
2536 posts
Joined: June 2008
Offline
My guess is that ZMAX gets extended each time the loop iterates. So create an external variable, outside the loop, that you can use as a constant inside the loop.

Attachments:
Untitled-2.jpg (190.3 KB)
ap_zmax_forloop.hipnc.hiplc (53.1 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
1104 posts
Joined: Aug. 2008
Offline
Well I want the current $ZMAX of the current itteration and transform the box with that value, so I could have differently sized boxes and yet stack them up neatly. I am not sure this solution would solve that ?
/M

Personal Houdini test videos, http://vimeo.com/magnusl3d/ [vimeo.com]
User Avatar
Member
1104 posts
Joined: Aug. 2008
Offline
Here is a solution for what I want todo that sort of work's not sure it handles all cases yet but for this test it does.
Edited by MagnusL3D - July 15, 2016 11:31:49

Attachments:
forloop2.hipnc (57.9 KB)

/M

Personal Houdini test videos, http://vimeo.com/magnusl3d/ [vimeo.com]
User Avatar
Member
182 posts
Joined: April 2009
Offline
It's happening because each iteration you offset an already offset box. If you chain multiple transform nodes with $ZMAX you get the same effect without the merging.
One way would be to fetch the geometry from the outside each time ( which you did in your second file ) or simply use $ZMAX - $ZMIN inside the loop instead.
User Avatar
Member
1104 posts
Joined: Aug. 2008
Offline
Thanks Blackpixel, yeah I figured it was doing something like that. Thats why I came up with my 2nd solution. And I tried yours out aswell, got it working but just one a single input mesh. Can't get it to work with different meshes for some reason.
/M

Personal Houdini test videos, http://vimeo.com/magnusl3d/ [vimeo.com]
User Avatar
Member
182 posts
Joined: April 2009
Offline
Yep, you are correct. Your second setup is the right way to go then
You can simplify it a bit though. Get rid of that attrib create and get the ZMAX from the bbox() expression directly in the transform : bbox( “../foreach_begin1”, D_ZMAX) + $ZMAX
  • Quick Links