I am using a sort node to randomize some point indices on a line. I am trying to change the seed and re randomize the order by control of a variable in a wrangle which is directly upstream of the sort node.
I cant get get the sort node to respond to my variable -@sortSeed it accepts it without error but treats it as 0.
The only way I have been able to workaround is to control the seed with a time based expression such as int(floor($F/30)) or whatever but this requires that change it is several places.
I am working with points and have tried the detail (and other) contexts as well.
I can see my variable in the Geometry Spreadsheet..
Surely I am missing something obvious.
If not is there another method I could use to do a random sort of point orders so that I could control the seed in a wrangle or vop? I have not seen any vex equivalent with my searches.
thanks in advance for any suggestions
jeff
using Sort and changing seed with an attribute
3605 2 0-
- jeffMc
- Member
- 126 posts
- Joined: April 2014
- Online
-
- old_school
- Staff
- 2540 posts
- Joined: July 2005
- Offline
Best to create a detail type attribute in your vex code to set your global control variable. You don't want to be setting globals as a per point or primitive attribute.
Then in the Sort SOP, you can use the detail() expression function to fetch the value of your detail attribute in to the seed parameter:
I like to use opinputpath() to fetch input names of SOPs to keep things procedural and reusable and HDA safe.
By using detail attributes as your global control variables, you are ensuring that updating and referencing these detail attributes should not cause a node to evaluate. YMMV
int mySeed = 10; // create a local variable and set to your seed value addattrib(0, "detail", "sortSeed", mySeed); // last step add detail attribute
Then in the Sort SOP, you can use the detail() expression function to fetch the value of your detail attribute in to the seed parameter:
detail(opinputpath(".",0), "sortSeed", 0)
I like to use opinputpath() to fetch input names of SOPs to keep things procedural and reusable and HDA safe.
By using detail attributes as your global control variables, you are ensuring that updating and referencing these detail attributes should not cause a node to evaluate. YMMV
There's at least one school like the old school!
-
- jeffMc
- Member
- 126 posts
- Joined: April 2014
- Online
-
- Quick Links

