Search - User list
Full Version: Python script node, getting absolute path
Root » PDG/TOPs » Python script node, getting absolute path
perpen
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!
tpetrick
You can do the following to get the path to the TOP node:

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.
perpen
Thanks!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB