I have the following python code:
myNode = hou.node(hou.pwd())
myNode.parm('export_metaball_execute').pressButton()
myNode.parm('export_sphere_execute').pressButton()
I use it as a call back for a button in my HDA, this button is supposed to activate two other buttons at the same time (or one after another). I tested a version of this script and it worked in the python shell but not as a callback in the button. Can anybody help me figure out why?!
Cheers
PS: Check file and OTL attached
Issues with Python callback in an HDA
4826 3 1- rafaels
- Member
- 694 posts
- Joined: March 2009
- Online
Toronto - ON
My Houdini playground [renderfarm.tumblr.com]
“As technology advances, the rendering time remains constant.”
My Houdini playground [renderfarm.tumblr.com]
“As technology advances, the rendering time remains constant.”
- graham
- Member
- 1904 posts
- Joined: Nov. 2006
- Offline
Looking at your file there are two problems:
The first is that your first assignment, myNode = hou.node(hou.pwd()) is incorrect. hou.pwd() returns an instance of hou.Node, and attempting to wrap that in a call to hou.node() generates a syntax error. For this you really don't even need to bother to assign anything since you can just execute your callbacks from hou.pwd()
The second issue is that there are no multiline expressions in the callback field. In order to have it work properly you need to separate each statement using a ;.
The following works correctly:
hou.pwd().parm(“export_metaball_execute”).pressButton(); hou.pwd().parm(“export_sphere_execute”).pressButton()
The first is that your first assignment, myNode = hou.node(hou.pwd()) is incorrect. hou.pwd() returns an instance of hou.Node, and attempting to wrap that in a call to hou.node() generates a syntax error. For this you really don't even need to bother to assign anything since you can just execute your callbacks from hou.pwd()
The second issue is that there are no multiline expressions in the callback field. In order to have it work properly you need to separate each statement using a ;.
The following works correctly:
hou.pwd().parm(“export_metaball_execute”).pressButton(); hou.pwd().parm(“export_sphere_execute”).pressButton()
Graham Thompson, Technical Artist @ Rockstar Games
- rafaels
- Member
- 694 posts
- Joined: March 2009
- Online
Ok!! This actually starts to make sense to me now…
What would be the ideal procedure then if I wanted to create a definition in Python and have it run as a callback within that HDA?
I can imagine that I could build that definition into the HDA and then it would be readily available in the callback, right?! Is that generally better than calling multi-line expressions?
Thanks a million!
What would be the ideal procedure then if I wanted to create a definition in Python and have it run as a callback within that HDA?
I can imagine that I could build that definition into the HDA and then it would be readily available in the callback, right?! Is that generally better than calling multi-line expressions?
Thanks a million!
Toronto - ON
My Houdini playground [renderfarm.tumblr.com]
“As technology advances, the rendering time remains constant.”
My Houdini playground [renderfarm.tumblr.com]
“As technology advances, the rendering time remains constant.”
- graham
- Member
- 1904 posts
- Joined: Nov. 2006
- Offline
That's right! You can use the assets Python Module to create function definitions and call those from your callback.
Information about adding python scripts in assets can be found here:
http://www.sidefx.com/docs/houdini10.0/hom/assetscripts [sidefx.com]
Information about adding python scripts in assets can be found here:
http://www.sidefx.com/docs/houdini10.0/hom/assetscripts [sidefx.com]
Graham Thompson, Technical Artist @ Rockstar Games
-
- Quick Links