Jump to content

Questions about nodes and connections


vbk!!!

Recommended Posts

Hi,

 

I am coming to python in Houdini to modify a mocap rigs. I would like to add Null between the bones.

If I discovered the input and output methods in the hou.Node, it's still a bit frustrating since it takes the in account the connections and not the hierarchy.

 

So ... is there a way to get all the child nodes from a selected one ( i mean to selected the master null and get all the bone in a tuple) ?

 

Thanks for your help

 

Vincent

Link to comment
Share on other sites

You can use the code below in Python source editor.

allChildren = []
def getChildrenFromSelected():
    selectedNodes = hou.selectedNodes()
    for node in selectedNodes:
        getChildren(node)
    print allChildren
    # Process All Children Nodes

def getChildren(node):
    for child in node.children():
        allChildren.append(child)
        getChildren(child)

Then select your parent node and call, hou.session.getChildrenFromSelected()

 

Hope it helps.

Link to comment
Share on other sites

sorry but i don't want to dive in a node to get what is inside.

to quote the documentation : "Using the file system analogy, a node’s children are like the contents of a folder/directory." I don't want that

 

 

Using a selected node in Scene Level I would like to get all the childrens of this node ( not its content but its "network").

Sorry if I am not clear ... but in Houdini, children means 2 different things :(

 

 

Vincent

Link to comment
Share on other sites

Hi,

 

I think I understand what do you mean by "children".

e.g. Below is a hierarchy of nodes at /obj level.

 

post-9105-0-53778200-1403059041_thumb.jp

 

I checked various node methods in python but so far only variations of input/output methods are able to access the hierarchy above.

Do you have a mix of connection nodes & hierarchy nodes you are after? (And that's why you want to isolate the children?)

 

Link to comment
Share on other sites

You can traverse the tree with node.outputs()

import hou

def goDownTree(oNodes):
    """Recursively travel on output nodes"""
    for oNode in oNodes:
        print(oNode.name())
        goDownTree(oNode.outputs())

print("----")
oSel = hou.selectedNodes()
for oNode in oSel:
    print("selected: "+ str(oNode))
    print("children: ")
    goDownTree(oNode.outputs())
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...