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

Python::Finde all nodes of one type, all versions


let's say I have a node called io::caching::2.1, where 2.1 is the version, and io is the namespace. but the scene has many nodes of this type, but with different versions, is there a way to get all the nodes with all versions, without looping over the complete scene?



Share this post

Link to post
Share on other sites

If your objects are just thrown all over the entire /obj root, then yes, you have to loop over all of them. But if you organize them into subnets you can loop over only the children of a subnet, or any object. Like all nodes inside a geo for instance.

In this example code I am filtering by .type() but you could alter the IF/THEN statement to examine the .name() instead.

def childrenOfNode(node, filter):
    # Return child 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))                          # name~type.
                    result += childrenOfNode(n, filter)
    return result
nodes = childrenOfNode(hou.node("/obj/my_subnet/),["Object null"])                     # Fetch any null object nodes inside this subnet.


Edited by Atom

Share this post

Link to post
Share on other sites

The best way is to find the corresponding node types you want to search for and check for all instances of those types.  For example, if your node is a SOP:

key = ("io", "caching")

all_instances = []

for node_type in hou.sopNodeTypeCategory().nodeTypes().values():
    components = node_type.nameComponents()

    if components[1:3] == key:


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