Jump to content

forEach vs forEach subnet problem


Recommended Posts

Trying to use an attribute to drive random values in a carve. Works in subnet foreach but not new for each.


As far as I'm aware the carve can't use $PR etc directly so I'm using the prim function in a forEach loop. Just a bit confused as to whats going on.

If I create the setup in a "new" foreach loop I'm getting the same U value for each curve, but If I create the carve and use the prim attribute in a subnet for each loop it works fine. Now I'm guessing theres something different in how these two operate. AforLoopCarveProblem.hips I can't use PR I'm using 0 in the loop, and the subnet (as far as I can tell) culls each primitive into its own geometry?? So this works?

But the new foreach loop will just take the value of primitive 0 and apply it to every iteration?

Or am I way of base here, Confused.


Link to comment
Share on other sites

You gotta use the Create Meta Import Node

and use the iteration number. Then you can use this on your carve 

rand(detail("../foreach_begin1_metadata1/", "iteration", 0))


Edited by Sepu
Link to comment
Share on other sites

Thanks very much, I got it to work per your advice, however its all contained within the carve now. This is using iteration as the attribute for each primitive, which is fine, but what if I wanted this value to be driven by 'dist' attribute, created outside the for loop and call it in? Like in my example scene?

i.e. for each 'iteration' use 'dist'



Link to comment
Share on other sites

As David mention you do not have to use for each for this, but if you want to know 

You can also do this on the carve then you will get the same as your old for each.

fit01(rand(detail("../foreach_begin1_metadata1/", "iteration", 0)),0,.5)

or you could also do it with a couple of wrangle to get control, like in the hipnc




Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...