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
8287 2 0-
- perpen
- Member
- 60 posts
- Joined: 4月 2006
- オフライン
-
- tpetrick
- スタッフ
- 624 posts
- Joined: 5月 2014
- オフライン
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 - 2019年6月26日 17:20:33
-
- perpen
- Member
- 60 posts
- Joined: 4月 2006
- オフライン
-
- Quick Links

