Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

How can we List all blendshape nodes of a object?

How can we List all blendshape nodes of a object?

5rivamsi
Contributor Contributor
2,808 Views
6 Replies
Message 1 of 7

How can we List all blendshape nodes of a object?

5rivamsi
Contributor
Contributor

I tried this

shapes = mc.listConnections(objectShape,s=1,type = 'blendShape')

however it gave only one (most recent one) output while the object has 3 shapes.

later i tried

with shapeEditorManger, it listed all blendshapes in scene, I wanted only particular object's.

0 Likes
Accepted solutions (1)
2,809 Views
6 Replies
Replies (6)
Message 2 of 7

5rivamsi
Contributor
Contributor

 

def getHistoryNodes(sel, type):
sortedList = []
for aNode in mc.listHistory(sel):
if mc.nodeType(aNode) == type:
sortedList.append(aNode)
return sortedList
selected = mc.ls(sl=1)[0]
print (getHistoryNodes(selected, 'blendShape'))

 

 

lost sourcelink

0 Likes
Message 3 of 7

mcw0
Advisor
Advisor
Accepted solution

You can also use "getChain" and filter non-blendShape nodes.

0 Likes
Message 4 of 7

zewt
Collaborator
Collaborator

You definitely don't want to use listHistory.  That'll include blendShapes on other shape nodes that aren't actually deforming that shape, like blendShapes deforming upstream blendShape targets or morph targets.

0 Likes
Message 5 of 7

mcw0
Advisor
Advisor

Unfortunately, getChain isn't as useful as it could be.  It doesn't return the list of deformers in order.  😞  So I have to use listHistory in conjunction with getChain to get what I want.  Uh Maya...hint, hint.

Message 6 of 7

zewt
Collaborator
Collaborator

Try listHistory with -pruneDagObjects 1, which will make it stop if it reaches a different shape.  I'm not sure if there are any other gotchas, but that's what the input/output button in the toolbar uses.  With PyMEL:

 

import pymel.core as pm
for node in pm.ls(sl=True):
    print(node.listHistory(pruneDagObjects=True, type='blendShape'))

 

I wouldn't use getChain.  It looks like an ancient bit of MEL that nothing in Maya itself is actually using (usually a bad sign), and it looks like it hasn't been updated for 2022.  It still assumes groupParts nodes exist for deformers, which they usually no longer do, and at a quick look it seems to make bad assumptions about groupParts nodes (it seems to assume there will never be two groupParts nodes in a row, which happened all the time).  That's probably why it's not returning results in the correct order.

 

0 Likes
Message 7 of 7

mcw0
Advisor
Advisor

Thank you very much!!!