How to change the weights of a deformer from a script in Maya?
This question is ideally for Pymel
in Maya 2013
, but if it is not possible I would still be interested to know the answer in Python
, MEL
, or using the C++ Maya-API
.
for deformers, you can query weight in python as :
VertexNb = cmds.polyEvaluate(Mesh, v=1) - 1
weight = cmds.getAttr('{0}.weightList[0].weights[0:{1}]'.format(deformerNode, VertexNb))
for blendshape :
VertexNb = cmds.polyEvaluate(Mesh, v=1)
weight = cmds.getAttr('{0}.inputTarget[0].baseWeights[0:{1}]'.format(blendShapeNode, VertexNb))
To set value :
cmds.setAttr('{0}.weightList[0].weights[0:{1}]'.format(deformerNode, VertexNb), *weight, size=len(weight))