Question - are your results that are inside of rigLs truly the direct
result of a call to cmds.listRelatives()?  Are you sure that the objects
inside of rigLs are truly strings (or unicode)?

I ask because I've noticed that in maya 2015, a repr was added to
MObjects... which would be nice, except that the definition really would
have been more appropriate for __str__, not __repr__, as it can make it
hard to tell that you are working with MObjects, and not just strings.

To see what I mean, try running this in Maya 2015*:

import maya.cmds as cmds
# set up the indicated hierarchy
cmds.createNode('transform', name='male01')
cmds.group(name='characterRig')
cmds.group(name='SceneGrp')
# and set up rigLs / charLs as indicated
rigLs = [u'male01', u'female01', u'elderly01']
parent = '|SceneGrp|characterRig'
charLs = cmds.listRelatives(parent, c=True)print charLs# [u'male01']
# this works as expected...
diff1 = list(set(charLs)-set(rigLs))print diff1# []
diff2 = list(set(rigLs)-set(charLs))print diff2# [u'female01', u'elderly01']
# but if you were to somehow end up with MObjects, the results may
seem confusing
def apiGetChildren(parent):
    # you can ignore the inner workings of this, just know that it will act like
    # cmds.listRelatives(parent, c=True), except return api MObjects
    import maya.OpenMaya as om
    sel = om.MSelectionList()
    sel.add(parent)
    parentObj = om.MObject()
    sel.getDependNode(0, parentObj)
    parentMFn = om.MFnDagNode(parentObj)
    return [parentMFn.child(i) for i in xrange(parentMFn.childCount())]

charLs = apiGetChildren(parent)
# in maya2015, charLs now SEEMS to be the same as before...print
charLs# [u'male01']
# ...but you'll get unexpected results...
diff1 = list(set(charLs)-set(rigLs))print diff1# [u'male01']
diff2 = list(set(rigLs)-set(charLs))print diff2# [u'male01',
u'female01', u'elderly01']

​
If you think something like this is going on, you can do this:

print charLsprint [type(x) for x in charLs]print rigLsprint [type(x)
for x in rigLs]

​
...and let us know what you get.

- Paul

*Note, I wasn't actually able to test this in Maya 2015, but it should act
like this from what I recall. Not 100% sure that the MObject.__repr__
returns unicode, as opposed to just str, though...

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAAssL7ayfYqscBsnEEBLCnsMObhS2TyHOzsUhtvQ_Hfx3Zf%3D0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to