Calling a function on button press

   6169   4   1
User Avatar
Member
52 posts
Joined: June 2009
Offline
Hi Everyone,

Is it possible to call a function defined in the codes section of a python SOP node on pressing a button of the same node.?

Thanks a lot in advance.
User Avatar
Member
1906 posts
Joined: Nov. 2006
Offline
Technically it is possible to do something like this using exec() on the contents of the assets “PythonCook” section but it won't really work and will raise an exception in 99% of cases.

The correct way is to define the function in the PythonModule and then have your cook code and your button callback access it from there.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
52 posts
Joined: June 2009
Offline
Cheers Graham….
User Avatar
Member
30 posts
Joined: July 2005
Offline
I know this is stale, but I was searching on this sort of thing.

What's wrong with putting this in the callback for the button:

hou.node('.').hdaModule().foo()

to call the HDA's foo function?

-caleb
My avatar was rendered from PRISMS
User Avatar
Member
126 posts
Joined: Aug. 2010
Offline
Dead thread, but still an issue. They should really get a Stackoverflow running for houdini since some questions remains relevant for a long period.

The issue with calling a HDA method with a callback is that errors won't be raise on the node but straight to the console. Workflow wise this can be rather confusing.
  • Quick Links