Skip to main content
Houdini tips

Houdini quick tip: random seed for your HDA instances

By November 6, 2018No Comments

Sometimes you need each instance of an HDA to have a random seed for internal use. Sometimes you just can’t be arsed to do it yourself. This’ll do it – create a seed parameter in the UI, and then stick this in the onCreated handler to set it automatically on creation:

[code language=”python”]node = kwargs[‘node’] seed = 6173*node.sessionId()+4139;
node.parm(‘seed’).set(seed % 10000)[/code]

From Leaf on the SideFX forums, who adds: “Explicitly setting the seed parameter on node create is the safest approach. Basing the seed on the node name can quickly cause problems when you go to clean up your scene and re-name everything (Toootally never accidentally done that before :)”

Leave a Reply