using the new pymel, dealing with instances is trivial because it uses the api behind the scenes to do the queries:
# assuming you have an instance named pCube2|pCubeShape1.... p = PyNode( 'pCube2|pCubeShape1' ) p.isInstanced() # Result: True # p.getInstances() # Result: [Mesh(u'pCube1|pCubeShape1'), Mesh(u'pCube2|pCubeShape1')] # p.getOtherInstances() #instances other than self # Result: [Mesh(u'pCube1|pCubeShape1')] # folks, we're so close to releasing, i can almost taste it! i've just been working on 8.5 compatibility code mostly, and regression tests and letting it burn in a little longer to weed out any more little bugs. i'll probably release one last RC, maybe tonight. -chad On Mar 12, 2009, at 4:33 PM, ryant wrote: > > If shape has two parent transforms it must be an instance right? > > import maya.cmds as cmds > > sphere = cmds.polySphere() > cmds.instance(sphere) > > getShape = cmds.listRelatives(sphere, shapes=True) > parents = cmds.listRelatives(getShape[0], allParents=True) > if len(parents) > 1: > print getShape[0], "is an instance" > > RyanT > Technical Artist > www.rtrowbridge.com/blog > NaughtyDog Inc. > > On Mar 12, 4:21 pm, yury nedelin <[email protected]> wrote: >> hi this is not really python specific but >> >> what i a nice way to tell if object is an instance with mel/python? >> >> Yury > > --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---
