Guest User

Maya node traversal example

a guest
Feb 4th, 2012
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. def traverse(node):
  2.     print ' ' * traverse.level + ' ' + node
  3.     children = cmds.listRelatives(node, children=True, fullPath=True)
  4.     if children:
  5.         for child in children:
  6.             traverse.level += 1
  7.             traverse(child)
  8.             traverse.level -= 1
  9.  
  10. traverse.level = 1
  11. nodes = cmds.ls('|*')
  12. for node in nodes:
  13.     traverse(node)
Advertisement
Add Comment
Please, Sign In to add comment