Run Function from PYTHON SOP

   8501   6   2
User Avatar
Member
460 posts
Joined: July 2005
Offline
Hi guys

I have a python SOP with a few things on it,
all those things are different functions that I want to
trigger with buttons, so how do I do it?

I know that in a regular HDA I use hou.phm().hello() for example

but for the Python SOP that doesn't work cause the code is NOT in the
same place.

see the image as an example
clicking the button will run hello() function

THanks

Attachments:
pySop.png (75.0 KB)

varomix - Founder | Educator @ Mix Training
Technical Artist @ Meta Reality Labs
User Avatar
Member
1905 posts
Joined: Nov. 2006
Offline
The code section is not like the PythonModule: you cannot call functions from it. You'll need to put your code in the normal PythonModule to be able to call it from a callback.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
460 posts
Joined: July 2005
Offline
I'm messing with geometry so I need to do it this way

right?

cause the other way it's gonna complaint that the geometry is read-only

any ideas?

thanks
varomix - Founder | Educator @ Mix Training
Technical Artist @ Meta Reality Labs
User Avatar
Member
12448 posts
Joined: July 2005
Offline
If you have a parameter-less node like this, then your Cook button can simple force a cook of the node (eg. opcook -F .) and it'll execute the entire Python code section. I assume you are making a no-input “generator” type SOP. Any parameters you create on the node will also trigger a cook of the node.
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
User Avatar
Member
460 posts
Joined: July 2005
Offline
the thing is I want to have 2 buttons

one executes a function
and the other one does another function

thanks
varomix - Founder | Educator @ Mix Training
Technical Artist @ Meta Reality Labs
User Avatar
Member
7714 posts
Joined: July 2005
Offline
Parameter buttons should not modify node data. They should just modify parameters. Forcing a recook should not even be needed because whoever needs the data (eg the viewport) will just naturally recook after the callback finishes.
User Avatar
Member
345 posts
Joined:
Offline
I have nothing to add, just second all above. Code section is not going to work with the buttons since it is cooked every time. I'm not exactly sure what you heading for but perhaps what you want to do is to split Code section into several separate python sops embedded inside parent HDA with all the ‘trigger’ functions…
  • Quick Links