While working on a command today, I stumbled across something that perhaps
someone could either explain or confirm as a bug.
Specifically, when I set the type filter on an MItSelectionList object to
MFn.kDagNode, it will properly ignore ordinary dependency nodes, but does
not filter out plugs! You can confirm this with the following simple
example:
import maya.OpenMaya as OM
import maya.cmds as cmds
locator1 = cmds.spaceLocator()
mathNode = cmds.createNode("multMatrix")
locator2 = cmds.spaceLocator()
sList = OM.MSelectionList()
sList.add(locator1[0])
sList.add(locator1[0]+".rotateX")
sList.add(mathNode)
sList.add(locator2[0])
sList.add("locatorShape"+locator2[0].lstrip("locator"))
sListAsStrings = []
sList.getSelectionStrings(sListAsStrings)
print "List: %s" % sListAsStrings
iter = OM.MItSelectionList(sList, OM.MFn.kDagNode)
while not iter.isDone():
objectName = []
iter.getStrings(objectName)
if iter.itemType() is not OM.MItSelectionList.kDagSelectionItem:
print "%s is not a valid dagpath. It is item type %s" % (objectName[0],
iter.itemType())
else:
print "%s is a valid dagpath" % objectName[0]
iter.next()
You should end up with something like:
List: [u'locator1', u'locator1.rotateX', u'multMatrix1', u'locator2',
u'locatorShape2']
locator1 is a valid dagpath
locator1.rotateX is not a valid dagpath. It is item type 3
locator2 is a valid dagpath
locatorShape2 is a valid dagpath
--
http://groups.google.com/group/python_inside_maya