Hello,
Is there a way to get a reference like kwargs= "node" inside of the Python module of an HDA?
In the python module, hou.pwd() returns the geo node and the kwargs dictionary only contains 'type'.
Kind regards,
Joris
Referencing an HDA instance in it's Python module
968 2 2- Jehs_Joris
- Member
- 5 posts
- Joined: Sept. 2020
- Offline
- graham
- Member
- 1914 posts
- Joined: Nov. 2006
- Offline
Using hou.pwd() inside a PythonModule section is not recommended and it only "works" due to the fact that whatever code is calling that code is being run under the context of an instance of your digital asset.
You would be best to think of the PythonModule section as more like a proper Python module file on disk specifically for your node type that has no concept of Houdini (other than if you need to set something up using the kwargs hou.NodeType during module initialization) and explicitly pass a hou.Node instance to any code in there that needs that.
Something like this as a callback or menu script:
is a better idea than something like this where it's relying on myfunc() to take no args and call hou.pwd() internally
You would be best to think of the PythonModule section as more like a proper Python module file on disk specifically for your node type that has no concept of Houdini (other than if you need to set something up using the kwargs hou.NodeType during module initialization) and explicitly pass a hou.Node instance to any code in there that needs that.
Something like this as a callback or menu script:
hou.pwd().hdaModule().myfunc(hou.pwd())
hou.pwd().hdaModule().myfunc()
Graham Thompson, Technical Artist @ Rockstar Games
- Jehs_Joris
- Member
- 5 posts
- Joined: Sept. 2020
- Offline
-
- Quick Links