getting the lowest node from the highest one in python

   418   2   0
User Avatar
12 posts
Joined: Jan. 2023
Hi, I've got this hierarchy in Solaris and from the top-most node cone1 I want to get the USD ROP node that's at the bottom of the hierarchy:

When I use UI dependencies window, the USD ROP is there:

but when I access cone1's dependencies with python, the tuple only contains the node itself, no dependents:

I tried with include_children flag True and False, same with .references.

(<hou.LopNode of type cone at /stage/cone1>,)

How do I get the USD ROP from /stage/cone1 node without resorting to recursion?
Edited by KatanaPoland - April 19, 2024 05:52:55

Screenshot_3.png (11.9 KB)
Screenshot_4.png (16.8 KB)

User Avatar
2574 posts
Joined: June 2008
Maybe try node.children instead of node.dependents?

This is what I use to return children of a node.
def childrenOfNode(node, filter):
    # Return nodes of type matching the filter (i.e. geo etc...).
    result = []
    if node != None:
        for n in node.children():
            t = str(n.type())
            if t != None:
                for filter_item in filter:
                    if (t.find(filter_item) != -1):
                        # Filter nodes based upon passed list of strings.
                        result.append('%s~%s' % (, t))
                    result += childrenOfNode(n, filter)
    return result

And a usage case...
    # Export geo based objects as OBJ files.
    lst_geo_objs = []
    #nodes = childrenOfNode(hou.node(node_path),["envlight"])
    #nodes = childrenOfNode(hou.node(node_path),["hlight", "ambient"])
    nodes = childrenOfNode(hou.node(node_path),["Object geo"]) #Other valid filters are Sop, Object, cam.
    for node in nodes:
        ary = node.split("~")
        if len(ary) > 0:
            node_candidate = "%s/%s" % (node_path, ary[0])
            n = hou.node(node_candidate)
            if n !=None:
                if n.isDisplayFlagSet():
                    exportAsRIB(node_candidate, geo_dir)
Edited by Enivob - April 19, 2024 08:05:14
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
12 posts
Joined: Jan. 2023
Thanks for your reply @Enivob. Interestingly accessing node's children gives me an empty tuple, as if there are none
  • Quick Links