Presuming you have a head mesh called
Here's a tool that will add a new blendshape target mesh based on selection:
head
, that already has a blendshape node input called blendShape1
, add a new mesh called headShape3
as the next target in the list:import pymel.core as pm bsHeadMesh = pm.PyNode("head") bsNode = pm.PyNode("blendShape1") newTargMesh = pm.PyNode("headShape3") weightCount = pm.blendShape(bsNode, query=True, weightCount=True) pm.blendShape(bsNode, edit=True, target=[bsHeadMesh, weightCount, newTargMesh, 1])The
weightCount
is the number of current targets, which also gives you the 0-based index to add the next new target. The trailing 1
is how much influence should be used for the new target. Shoud probably always be 1
.Here's a tool that will add a new blendshape target mesh based on selection:
import pymel.core as pm def addBsTarget(): """ Select two mesh in order: A new target mesh, and the mesh with blendshape to add it to. """ sel = pm.ls(selection=True) if not len(sel) == 2: pm.displayError("Please select exactly two mesh, the target, and the base head.") return newTargetMesh = sel[0] bsMeshNode = sel[1] bsMeshShape = pm.listRelatives(bsMeshNode, shapes=True, type='mesh')[0] bsNode = pm.listConnections(bsMeshShape, source=True, destination=True, type='blendShape') if not bsNode: pm.displayError("Could find no blendShape node on mesh: %s"%sel[1]) return weightCount = pm.blendShape(bsNode, query=True, weightCount=True) pm.blendShape(bsNode, edit=True, target=[bsMeshNode, weightCount, newTargetMesh, 1]) pm.displayInfo("Added new blendshape target: %s"%sel[0])http://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/CommandsPython/blendShape.html