Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
Fyre

forEach vs forEach subnet problem

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

forLoopCarveProblem.hip

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.

 

Share this post


Link to post
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

Share this post


Link to post
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'

 

cheers

Share this post


Link to post
Share on other sites

You don't have to use foreach at all. See post here by Mawi: 

 

Share this post


Link to post
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

 

 

forLoopCarveProblem02.hipnc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0