query connected blendShape nodes

query connected blendShape nodes

bmagner888
Enthusiast Enthusiast
538 Views
1 Reply
Message 1 of 2

query connected blendShape nodes

bmagner888
Enthusiast
Enthusiast

for various rigging functions and situations, it's necessary to acquire the blendShape nodes connected to scene objects.  I had working methods up until Maya 23.


Previously,  I used this:

blendShapes = pm.listConnections(shapeNode, type='blendShape', scn=True)

But then it stopped working in Maya 22 and I had to query for objectSets...

objectSets = pm.listConnections(shp,s=True, type = 'objectSet', scn=True)
    if objectSets:
        for objSet in objectSets:
        lst = pm.listConnections(objSet, type = 'blendShape', scn=True)
       for ths in lst:

           if not ths in blendShapes:

                 blendShapes.append(ths)

But now in Maya 23, there's a long chain of intermediate nodes (see image). 

Is there some shortcut to just get the connected blendShape nodes on my meshes without having to devise some overly complex reverse daisy-chain search?

bs_bs.jpg

0 Likes
Accepted solutions (1)
539 Views
1 Reply
Reply (1)
Message 2 of 2

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

Instead of daisychaining using a while loop, you can just get all of the connected history and then query the objecttype:

import maya.cmds as mc

historyNodes = mc.listHistory(shapeNode)
blendshapes = []
for h in historyNodes:
    if mc.objectType(h) == "blendShape":
        blendshapes.append(h)

This should also work in all of the maya versions and in all configurations. Since your previous methods would have only worked if there are no other deformers higher in the deformationhierarchy than your blendshape.

 

I hope it helps!