Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0

Loop for all nodes

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.


Share this post

Link to post
Share on other sites

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)


Share this post

Link to post
Share on other sites

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


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 person likes this

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0