Jump to content
JDee

Random value every iteration in ForEachLoop

Recommended Posts

Hi
Is there a way to get a random value in ForEachLoop (say between 1 and 0) using iteration number in the loop as a seed for it ?

Edited by JDee

Share this post


Link to post
Share on other sites

On the Block Begin node, click "Create Meta Import Node", lets name it "meta". Then refer to it like this:

- in the wrangle:
 

int seed = detail(1,"iteration");

- If you don't want VEX, but you want expression, then use it like this:
 

detail(1,"iteration",0)

- or expression anywhere, relative path:

detail("../meta","iteration",0)

I have attached the file.

 

 

forseed.hiplc

forseed.PNG

Edited by ikoon
  • Like 2

Share this post


Link to post
Share on other sites

It's much appreciated ikoon!
I'm trying to feed that value to distance value in attribute transfer (thresholddist parameter) with no luck, how to properly hook it up in that approach ?
So every iteration the distance is randomly different in that range.
Thanks.

Edited by JDee

Share this post


Link to post
Share on other sites

I see... for loop doesn't seem to fetch/accumulate each attribute iteration separately. Could you use Point Cloud then? Instead of the Attribute Transfer. If you send the scene file, maybe somebody could look at it. (I will be busy next days)

Edit: Btw the "SOP Solver" approach may be helpful now.

Edited by ikoon

Share this post


Link to post
Share on other sites

Thanks for this! Yes this is what I'm struggling with now.
I have more complex scene, but I made a simple scheme in this hip file, just in case if there is any tricky thing to work it out.
All I want to get is random distance on every iteration for the attribtransfer.

FLoop_attribtransfer.hip

FL.jpg

Share this post


Link to post
Share on other sites

I thought, that we have multiple "from" nodes, each having different thresholddist and that we are transfering to all the "to" points :). From circle points to grid. That wasn't working for me in the For Loop:

grid.PNG

Share this post


Link to post
Share on other sites

It's really serious hip file goddamn! Thanks Noobini for that.
Had to post the sample scene right away.Sorry.

Share this post


Link to post
Share on other sites

01) you're missing a bracket in the transform, you have to get rid of the red  warning signs !!

02) once you sorted out the brackets...it IS working but because the random rotation is between 0 and 1 (degrees) it is tiny for you to actually see.

03) to magnify the effect for you to see mult by 360, ie. 360*rand(detail(-1,"iteration",0)), so it means random rotation between 0 and 360 degrees.

04) you have to run the loop on each connected piece, ie. a box is treated as one...not 6 separate prims.

 

vu_RandomTransform.hipnc

  • Thanks 1

Share this post


Link to post
Share on other sites

Nice. I was now playing around with combining this with $F and came as far as this:

fit(rand(detail(-1,"iteration",0)+$F), 0, 1 , 0, 360)

How could i make this go slower? when i divide it at the end, it's not from 0 to 360 anymore. I also want them to start at a totally random position.

Share this post


Link to post
Share on other sites

Hello

could someone please explain to me
what is (-1) meaning in this: detail(-1,"iteration",0)?

And what is the "spare input 0"?
Thanks.

Share this post


Link to post
Share on other sites

in the parameter editor, if you click the cog icon - add spare input, it will add a string parameter where you can plug a node path you can reference to.

So instead of detail(1,"iteration",0),detail(2,"iteration",0),detail(3,"iteration",0) referring to the node connected on input 2,3 and 4,

You can use detail(-1,"iteration",0),detail(-2,"iteration",0) referring to the spare parm you just added (-1 is the first spare parm, -2 is the second and so on)

Share this post


Link to post
Share on other sites
On 3/20/2019 at 9:57 PM, Krion said:

Nice. I was now playing around with combining this with $F and came as far as this:

fit(rand(detail(-1,"iteration",0)+$F), 0, 1 , 0, 360)

How could i make this go slower? when i divide it at the end, it's not from 0 to 360 anymore. I also want them to start at a totally random position.

HI, to make it slower you need to divide only the $F, not the entire result, otherwise it won t keep anymore your fitted values. 

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

×