Hi,
What would be the proper way to get the absolute path of the Python Script node I am in, inside a top network? The hou.pwd() doesn't work in this context. And I couldn't find a way to get that info using ‘self’ either, the closets I got was self.name and self.context.names() for the parent node.
Thanks!
Python script node, getting absolute path
5544 2 0- perpen
- Member
- 59 posts
- Joined: April 2006
- Offline
- tpetrick
- Staff
- 585 posts
- Joined: May 2014
- Offline
You can do the following to get the path to the TOP node:
The code in the Python Script node is evaluated in PDG's Python context, and the self object is a reference to the underyling PDG node. Depending on the parameters, the script may be evaluated in the current process or out of process/on the farm. When evaluated in-process the code runs on a background thread, and it's generally unsafe to make modifications to the Houdini session using the hou module. It's fine to look up the path, but constructing nodes/changing parameters in unsupported.
import hou node = hou.nodeBySessionId(self.customId) print node.path()
The code in the Python Script node is evaluated in PDG's Python context, and the self object is a reference to the underyling PDG node. Depending on the parameters, the script may be evaluated in the current process or out of process/on the farm. When evaluated in-process the code runs on a background thread, and it's generally unsafe to make modifications to the Houdini session using the hou module. It's fine to look up the path, but constructing nodes/changing parameters in unsupported.
Edited by tpetrick - June 26, 2019 17:20:33
- perpen
- Member
- 59 posts
- Joined: April 2006
- Offline
-
- Quick Links