Python : get all the nodes of a hierarchie

   5353   4   2
User Avatar
Member
383 posts
Joined:
Offline
Hello,

I have a bone rig. I would like to get the list of all the bones, selecting only the master (null).
I can't see how to do it with Python.

Thanks for your help.

Vincent
http://vimeo.com/vbkstudio [vimeo.com]
User Avatar
Member
23 posts
Joined: Sept. 2015
Offline
Hi,

You can recursively call hou.node(“path/to_your/node”).outputs() for that
outputs() returns all output nodes found for the given node.
http://cgtoolbox.com/ [cgtoolbox.com] Houdini tools and scripts for free ! :)
User Avatar
Member
383 posts
Joined:
Offline
ok …
I guess it's time to learn about recursive call and function !
http://vimeo.com/vbkstudio [vimeo.com]
User Avatar
Member
23 posts
Joined: Sept. 2015
Offline
Here is a small example if that can help you

def findOutputs(node, result):

outputs = node.outputs()

if outputs:
result += outputs

for n in outputs:
findOutputs(n, result)

startNode = hou.selectedNodes()
result =
findOutputs(startNode, result)

all the output nodes will be stored in the result list
http://cgtoolbox.com/ [cgtoolbox.com] Houdini tools and scripts for free ! :)
User Avatar
Member
383 posts
Joined:
Offline
thanks

Following examples on the net, I made something like this :
root = hou.selectedNodes()
link=
def recurLinks(n):
for i in n.outputs():
link.append(i)
recurLinks(i)
return link

I don't know exactly how but … it seems to work !
http://vimeo.com/vbkstudio [vimeo.com]
  • Quick Links