如何从 Maya 中的脚本更改变形器的权重?

How to change the weights of a deformer from a script in Maya?

如何在 Maya 中通过脚本更改变形器的权重?

这个问题非常适合 Maya 2013 中的 Pymel,但如果不可能,我仍然有兴趣知道 PythonMEL 中的答案或者使用 C++ Maya-API.

对于变形器,您可以在 python 中查询权重,如:

VertexNb = cmds.polyEvaluate(Mesh, v=1) - 1
weight = cmds.getAttr('{0}.weightList[0].weights[0:{1}]'.format(deformerNode, VertexNb))

混合变形:

VertexNb = cmds.polyEvaluate(Mesh, v=1)
weight = cmds.getAttr('{0}.inputTarget[0].baseWeights[0:{1}]'.format(blendShapeNode, VertexNb))

设置值:

cmds.setAttr('{0}.weightList[0].weights[0:{1}]'.format(deformerNode, VertexNb), *weight, size=len(weight))