Referencing an HDA instance in it's Python module

   968   2   2
User Avatar
Member
5 posts
Joined: Sept. 2020
Offline
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
Edited by Jehs_Joris - Jan. 4, 2023 01:39:59
User Avatar
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:
hou.pwd().hdaModule().myfunc(hou.pwd())
is a better idea than something like this where it's relying on myfunc() to take no args and call hou.pwd() internally
hou.pwd().hdaModule().myfunc()
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
5 posts
Joined: Sept. 2020
Offline
Thank you for the answer! Good to know.
Unfortunately I noticed too late that using square brackets in my original post caused a word to be deleted. So, I was looking for a reference similar to ' kwargs= "node" '.
Using node('.') worked for me.
Edited by Jehs_Joris - Jan. 4, 2023 09:49:48
  • Quick Links