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' % (n.name(), 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) lst_geo_objs.append(node_candidate)