I'm trying to set all the weights on a skinned mesh to the same array
of values. When I run this script it doesn't change the weights.
Please let me know what my mistake is. Thank you!

import maya.OpenMaya as om
import maya.cmds as cmds
import maya.OpenMayaAnim as oma

om.MGlobal.clearSelectionList()
om.MGlobal.selectByName('skinCluster2')

sList = om.MSelectionList()
om.MGlobal.getActiveSelectionList(sList)
node2 = om.MObject()
sList.getDependNode( 0, node2)

skin2 = oma.MFnSkinCluster(node2)
skinPath2 = om.MDagPath()
index2 = 0
skin2.indexForOutputConnection(index2)
skin2.getPathAtIndex(index2,skinPath2)

geo2 = om.MItGeometry(skinPath2)
vertices = geo2.count()

for i in range(0, vertices):
    ind = om.MIntArray()
    nor = False
    point = geo2.position(om.MSpace.kWorld)
    doubleArray = om.MScriptUtil()
    doubleArray.createFromList([0.4, 0.2, 0.1, 0.3], 4)
    oldWgt = om.MDoubleArray()
    newWgt = om.MDoubleArray(doubleArray.asDoublePtr(), 0)
    print oldWgt
    skin2.setWeights(skinPath2, component, ind, newWgt, nor, oldWgt)

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to