Start Python Sop via button?

   854   2   1
User Avatar
Member
96 posts
Joined: Nov. 2017
Offline
Is there a way to start a Python Sop by calling one of its functions from a button, e.g. on the hda containig the py sop? Since the python script generates geometry I can't place it inside the hda's python section. And because the script otherwise evaluates each time I load the scene I want to start it with a button so it only evaluates if I want it to.

Is there a way to achieve that?

Cheers
Tom
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
I guess you could use an IF condition based on a integer parameter that increases its value every time you click the Button?
To force the cooking you can use hou.Node.cook(force=True) method.
User Avatar
Member
122 posts
Joined: June 2019
Offline
Tom Mangold
Since the python script generates geometry I can't place it inside the hda's python section.

Technically you can. You're still able to use write-access to hou.Geometry you just have to either create an object yourself or get a frozen geometry from any other sop by calling hou.Geometry.freeze

For programmable geometry I'd suggest to not abuse Python SOP but generate geometry in a regular python script and then assign this geometry to stash parameter of the Stash SOP.

This parameter is a regular one but holds geometry and as a regular parm it can be promoted to HDA so you won't have to use editable nodes or whatever.
  • Quick Links