tamagochy Posted April 23, 2017 Share Posted April 23, 2017 So i need to modify file path in all file and filecache nodes. I made python script and it works, but the problem is it works only for selected nodes. I cant find how to loop through all nodes in houdini script to find specific ones and make changes more automatically. Thanks! Quote Link to comment Share on other sites More sharing options...
Atom Posted April 23, 2017 Share Posted April 23, 2017 Here is a little snippet from an exporter I was working on. You can just review all nodes of a certain type inside a certain network path. 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 # Export geo based objects as RIB archives. node_path = '/obj' lst_geo_objs = [] 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, export_dir) Quote Link to comment Share on other sites More sharing options...
A.Hawkin Posted April 25, 2017 Share Posted April 25, 2017 Not sure if this is what you're looking for, but if you want to loop over for example all file nodes in your scene you could use hou.nodeType(). Example: import hou # Get sopNodeType for the file SOP file_nodes = hou.nodeType(hou.sopNodeTypeCategory(), "file") # Loop over all instances of the sopNodeType for node in file_nodes.instances(): print node.parm("file").eval() 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.