Getting value(s) from previous loop in for-each

   2335   6   1
User Avatar
Member
18 posts
Joined: Jan. 2020
Offline
Greetings,

I'm trying to build a procedurally generated randomly distributed stack of boxes using for loop (like a pyramid, but ununiform). My solution is in each loop, I generated a grid, randomly blast a few primitives (using group range) and extrude them. Now in my stack, the box in the next level must on top of another box in the lower level. So in the current loop, I have to be able to access the blasted grid from the previous iteration, and randomly blast from those grid. This is done repeatedly until I reached the desired level.

In programming, this should be simply by defining a variable to store the value to be used in the next iteration. Is there a way to do this in Houdini's for-each node?

Thank you

edit: added a WIP image
Edited by jttarigan - Oct. 6, 2021 03:34:50

Attachments:
for-loop.PNG (2.8 MB)

User Avatar
Member
238 posts
Joined: Nov. 2013
Offline
you can switch the foreach_begin1_metadata1 node to feedback and fetch the last iteration/
http://www.sekowfx.com [www.sekowfx.com]
User Avatar
Member
18 posts
Joined: Jan. 2020
Offline
thanks for the answer. It's the switch but I put it on "Merge each iteration". Basically I just randomly blast iteratively to the top grid and it will merge the iteration process.
User Avatar
Member
331 posts
Joined: April 2018
Online
Can you share a sketch of what your desired output is supposed to look like?
User Avatar
Member
18 posts
Joined: Jan. 2020
Offline
I want to make a house using stack of boxes as the image below.

Attachments:
house_box.PNG (1.8 MB)

User Avatar
Member
238 posts
Joined: Nov. 2013
Offline
no need to blast the face out.
You could do something like this in the transform Y pos param:
bbox('../fetch_feedback_meta',D_YMAX)
see attached hipfile

Attachments:
stack_boxes.hip (146.0 KB)

http://www.sekowfx.com [www.sekowfx.com]
User Avatar
Member
331 posts
Joined: April 2018
Online
I'm not sure if this is the result you're after

Edited by eikonoklastes - Oct. 10, 2021 01:24:43

Attachments:
For Each Stacking.hiplc (114.3 KB)

  • Quick Links