[Maya] Check if blendShape is based on a separate mesh or on the base mesh?

Hi,

Is there a way to know either in UI or in code if the blendShape is based on a separate mesh or on the base mesh?

You can see an illustration of the problem here:

Regards,
Ben

Your question makes me think there’s some misunderstanding about what exactly is going on with blendshapes and the shape editor.

A “blendshape” in this context means a single blendshape node.
A “Target” is a single sculpted shape that the blendshape node controls. A blendshape node often has many targets. Targets can live on the blendshape node itself, or can come from a separate mesh connected in (This is the distinction I think you’re actually looking for. I’ll call this a connected target)

Pushing the “Create Blend Shape” button with multiple objects selected creates a blendshape node that controls the last mesh you have selected. It also creates a connected target on that mesh for every other mesh you had selected. If you graphed connections in the node editor, you’d see a connection coming out of the connected mesh and into the blendshape node.
If you just deleted the connected meshes (ie, pCube2), the target would still exist with the shape, that shape will just be stored on the blendshape node instead of coming from the connected mesh.

On the other hand, pushing the “add target” button creates a new target, but without a connected mesh. If you wanted to, you could manually connect a mesh into the correct plug on the blendshape node (via node editor or code) and turn it into a connected target.

If you want to list all the shape connections that a blendshape node has incoming, this code will show you.

myBlendshapeName = 'blendShape1'
plugsToCheck = '{0}.inputTarget[*].inputTargetGroup[*].inputTargetItem[*].inputGeomTarget'.format(myBlendshapeName)
print cmds.listConnections(plugsToCheck, plugs=True, connections=True)

This will print something like:

[
  u'blendShape1.inputTarget[0].inputTargetGroup[0].inputTargetItem[6000].inputGeomTarget',
  u'pSphereShape2.worldMesh',
  u'blendShape1.inputTarget[0].inputTargetGroup[2].inputTargetItem[6000].inputGeomTarget',
  u'pSphereShape4.worldMesh'
]

Every pair of strings in that list is an input/output pair. Where the first item is the plug on the blendshape, and the second item in the list is the mesh that is connected into that.
If you look at the number in the brackets after “inputTargetGroup”, that will give you the target number

To find the target name for the target number, use a command like this. In this case “5” is my target number.
cmds.aliasAttr('blendShape1.weight[5]', query=True)

1 Like

@tfox_TD

Thanks for the detailed explanation. You are right about me misunderstanding between blendshape and target.

The code provided also works as expected. Basically, if the index does not appear in the print result, it does not have a connected target/separate mesh.

Have a great day ahead!