HDA Node Placement (Custom Color Code)

   2227   4   1
User Avatar
Member
333 posts
Joined: Oct. 2012
Offline
Hi,
i created a HDA that when its placed in the network editor, the node will get a random color code and also update one of my paramter with randomness. However I would like to improve the seed value, atm I seem to get exact similar values when i place them shortly after each other.

Is there a way I could improve the random seed to have more random colors.

In the Type Properties of the HDA under Script I have this script:


set foo = `system(date)`
set seed = `substr($foo, 14, 2)``substr($foo, 17, 2)`

set num = `rand($seed)`
set num1 = `rand($seed+14)`
set num2 = `rand($seed+23)`

opcolor -c $num $num1 $num2 $arg1

opparm $arg1 dcolor2 ($num $num1 $num2) tdisplay ( on ) display ( 1 ) picking ( on )
User Avatar
Member
14 posts
Joined: Jan. 2014
Offline
may be use generated random number as a seed for the next call ?
User Avatar
Member
333 posts
Joined: Oct. 2012
Offline
Hi Mila,
thanks for your suggestion.

I kind of fixed it with changing the variable seed, so the seconds will be the first position.

So i just flipped this part in the code:

set seed = `substr($foo, 17, 2)` `substr($foo, 14, 2)`
User Avatar
Staff
3455 posts
Joined: July 2005
Offline
you might just try something like this:
set num = `rand($seed)`
set num1 = `rand($seed*3214)`
set num2 = `rand($seed*122223)`

just giving the rand() VERY different numbers will help…
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
818 posts
Joined: Sept. 2013
Offline
Maybe you could use Python to generate the random values?
python -c “import random”;
set num = `pythonexprf(“random.random()”)`;
set num1 = `pythonexprf(“random.random()”)`;
set num2 = `pythonexprf(“random.random()”)`;
Andrew / アンドリュー
  • Quick Links