Nicolas Longchamps

Nicolas Longchamps

About Me

Expertise
Game Artist
Location
Canada
Website

Connect

Recent Forum Posts

Python function 'node.children()' March 15, 2018, 4:14 p.m.

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:
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('..')
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