pubObj = cmds.ls(type = "publishedRef")
rigLs = []
for item in pubObj:
nameSplit = item.split(':')
rigLs.append(nameSplit[0])
grpNode = cmds.ls("SceneGrp", type=grpNode.name())
check = cmds.objExists("|SceneGrp|characterRig")
charLs = cmds.listRelatives("|SceneGrp|characterRig", c=True)
# Assumingly the following are the items appended into the list
# rigLs : [u'male01', u'female01', u'elderly01']
# charLs :[u'male01']
diff1 = list(set(charLs)-set(rigLs))
# Results : [u'male01']
diff2 = list(set(rigLs)-set(charLs))
# Results : [u'male01', u'female01', u'elderly01']
--
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/35777d5c-62d6-4341-880b-9f3e5bd123e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
a = set([u'male01', u'female01', u'elderly01'])
b = set([u'male01'])
a.difference(b)
# {u'elderly01', u'female01'}
The operators are defined to map the methods of sets like union, difference, intersection, ...
--
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/25f35623-6420-461f-8fad-1627b326861a%40googlegroups.com.
If you can post an example where you show us the actual content of the two list you are comparing, it will be much easier to help you find what might be wrong.
Something like:
a = {1, 2, 3}
b = {2, 3, 4}
print a - b # Remove items from a that exist in b
# 1
print b - a # Remove items in b that exists in a
# 4
print a ^ b # Symmetrical difference between a and b
# [1, 4]
All the operations can be found here:
https://docs.python.org/2/library/sets.html#set-objects
--
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/25f35623-6420-461f-8fad-1627b326861a%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0-FrFeDYHPZ__qo4%3D5tASXkVU9_mJC1WcfU24anDbMyA%40mail.gmail.com.
publishedRef is an in-house module. [u'male01', u'female01', u'elderly01'] which is the same results as diff2 - in my first post...--
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/8c6d2887-13cb-418a-bf57-e9cd880354ee%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAGQH2FFw7NU0FqAfcaQAwkEkSO_8_ioHc5YUhKiJR_guXmTkwQ%40mail.gmail.com.
aren’t sets deprecated?
Certainly not! You may be thinking of the top of the link I posted above as reference. That is in regards to the “sets” module, which looks to have been merged into top-level Python functionality. Quite the opposite of deprecation. :)
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACt6GrnNbB%3Dbebgb%3DEAtNB6a_a9ZC10r2_54fdacOEMhP7An%2Bg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODSCeGf8ayk6YsdH6Ux5U4fa4feFzswT-2qK3dBcnztVw%40mail.gmail.com.
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']
print charLs
print [type(x) for x in charLs]
print rigLs
print [type(x) for x in rigLs]