Iterating down a hierachy

436 views
Skip to first unread message

Jeremy YeoKhoo

unread,
Nov 6, 2013, 1:53:11 AM11/6/13
to python_in...@googlegroups.com
Hey guys,

A relatively easy question for you Maya python API peeps. How would you traverse down a hierarchy of a DAG node. Essentially if a hierarchy tree has children of the same appended name, I want to duplicate a single tree of that child for every children


Thanks
-Jeremy

Justin Israel

unread,
Nov 6, 2013, 3:58:56 AM11/6/13
to python_in...@googlegroups.com
Would MItDag possibly w/ MSelectionList be what you are looking for to find and traverse?



--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e68f0135-5c94-4352-93f1-23f4677b624e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jeremy YeoKhoo

unread,
Nov 6, 2013, 6:36:16 PM11/6/13
to python_in...@googlegroups.com
Yes, I am thinking the MItDag would be the trick

What I am trying to do is while traversing down a specified hierarchy of a DAG object, finding several objects containing a particular string/name within its children nested at different levels.Returning the name of those objects. However, I am guessing because the search essentially using a naming convention and not of a DAG type, maya.cmds would be a faster approach rather than using the MItDag method


-Jeremy

Jeremy YeoKhoo

unread,
Nov 6, 2013, 8:37:43 PM11/6/13
to python_in...@googlegroups.com
Actually I started coding using the MitDag, and at the moment I want to find the deepest depth of a hierarchy. But realise that it doenst automatically allow me to do that.

dagIterator= OpenMaya.MItDag( OpenMaya.MItDag.kDepthFirst, OpenMaya.MFn.kInvalid )
selectionList = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getActiveSelectionList( selectionList )
dgPath= OpenMaya.MDagPath ()
selectionList.length()

selectionList.getDagPath(0, dgPath) 

dagIterator.reset(dgPath)
dagIterator.depth()



On Wednesday, 6 November 2013 16:53:11 UTC+10, Jeremy YeoKhoo wrote:
Reply all
Reply to author
Forward
0 new messages