i'm having problems getting reliable component MObjects. i can get a good MObject if i use an MSelectionList and put in the string for a component like a face. in the example below, i'm going to get two MObjects representing the same face to make sure that they evaluate as the same:
import maya.cmds as cmds import maya.OpenMaya as api s,h = cmds.polySphere() sel1 = api.MSelectionList() dag1 = api.MDagPath() obj1 = api.MObject() sel1.add( s + '.f[0]' ) sel1.getDagPath( 0, dag1, obj1) sel2 = api.MSelectionList() dag2 = api.MDagPath() obj2 = api.MObject() sel2.add( s + '.f[0]' ) sel1.getDagPath( 0, dag2, obj2) dag1 == dag2 # True obj1 == obj2 # True so far so good. the two objects are equal, as they should be, since they both represent 'pSphereShape1.f[0]'. now let's take one of those objects, and create two MItMeshPolygon iterators, both from the same object. then we'll get the MObject for the currentItem from each and compare. these should both also represent the same face, and yet they're not equal.... mit1 = api.MItMeshPolygon( dag1, obj1 ) mit2 = api.MItMeshPolygon( dag1, obj1 ) mit1.currentItem() == mit2.currentItem() # False what's going on here? is there a reliable way to get MObjects for components so that equality comparisons are meaningful without stringifying the name and putting that into an MSelectionList? -chad --~--~---------~--~----~------------~-------~--~----~ Yours, Maya-Python Club Team. -~----------~----~----~----~------~----~------~--~---
