Jump to content

Random value every iteration in ForEachLoop


JDee

Recommended Posts

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
Link to comment
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
Link to comment
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
Link to comment
Share on other sites

  • 1 year later...

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
Link to comment
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.

Link to comment
Share on other sites

  • 1 year later...

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)

  • Like 1
Link to comment
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. 

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.

Guest
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...