Hi big friends, i have a little question for you
it about python function ‘hou.node.children()’
that's returning always like this (<hou.SopNode of type sphere at /obj/geo1/subnet1/sphere1>,..)
it's seems like used absolute path for searching node look to me…
wonder how get relative path node not used absolute path.
like
(<hou.SopNode of type sphere at ./subnet1/sphere1.>,..) (when if current node is ‘/obj/geo1’)
have a any idea?
Python function 'node.children()'
20457 1 4- yhkim
- Member
- 1 posts
- Joined: 11月 2017
- Offline
- Nicolas Longchamps
- Member
- 37 posts
- Joined: 8月 2015
- Offline
All paths are absolute at the base. Relative paths are representations that are parsed by houdini to find the abs path of a node. They cant exist on their own and are meaningless without a relative point of origin.
use hou.node.relativePathTo(base_node) to get paths from one node to another.
In your case you can do this:
But given in this case you are simply getting the path from the parent, relative paths are not very useful here; pathToParent would return ‘..’ for every child node, which simply means “up one level”. pathToChild would simply return the name of the child node, because the parent is like the current directory.
If you do:
You should get the abs path of the parent node.
hou.node.children() will get nodes one level down. For all children, including chilren of children, i think you need to use hou.node.allSubChildren(). Relative path would be more useful in that case.
hope this helps
use hou.node.relativePathTo(base_node) to get paths from one node to another.
In your case you can do this:
chl = myNode.children() for child in chl: pathToParent = child.relativePathTo(myNode) pathToChild = myNode.relativePathTo(child)
But given in this case you are simply getting the path from the parent, relative paths are not very useful here; pathToParent would return ‘..’ for every child node, which simply means “up one level”. pathToChild would simply return the name of the child node, because the parent is like the current directory.
If you do:
child.node('..')
hou.node.children() will get nodes one level down. For all children, including chilren of children, i think you need to use hou.node.allSubChildren(). Relative path would be more useful in that case.
hope this helps
-
- Quick Links