I have a problem with some scenes files that I’ve got from my client, actually, the client of my client so I can’t ask them directly.
I’m not sure how these files were created, but AFAIK they are using Maya 2013.5, and I’m using 2013 for these tests.
I wrote a tool to round weights values, I get the weights with skinPercent, do the rounding process and then put them back with setAttr. It works fine with my scenes, but in these scenes, it doesn’t.
Doing some tests, I found the problem, but I don’t know why it happens.
The joints order that setAttr or getAttr have, differ from what skinPercent gives me, so instead of putting back the [Arm joint] weight in the Arm, it puts it back in the shoulder, totally breaking my skin weights.
Export weights, delete history, import weights fix this problem.
Why would this happen?
The bind Pose is also weird.
I can get the bindPose from an influence with dagPose, but I can’t get it from the transform node or the skinCluster.
This is the test code I wrote to get to this conclussion:
from maya import cmds
#select a vertex before running
def test():
shape = cmds.ls(sl=1, o=1)[0]
vertx = cmds.filterExpand( selectionMask=31 )
trans = cmds.listRelatives(shape, p=True, type='transform')[0]
#get Skin Cluster
shapeConn = cmds.listConnections(shape)
skinCl = cmds.ls( shapeConn, type= "skinCluster" )[0]
#Get Influences
joints = cmds.skinCluster(skinCl, q=True, inf=True)
bindPoses1 = cmds.dagPose(trans, q=True, bindPose=True)
print 'BindPose Try 1: ' + str(bindPoses1) #This gives me None
bindPoses2 = cmds.listConnections(skinCl + '.bindPose', d=False, s=True, type='dagPose')
print 'BindPose Try 2: ' + str(bindPoses2) #This gives me None
bindPoses3 = cmds.dagPose(joints[0], q=True, bp=True )
print 'BindPose Try 3: ' + str(bindPoses3) #This gives me the bindPose1
for vtx in vertx:
vtxID = vtx[vtx.find("[")+1:vtx.find("]")]
#Get Weights with skinPercent
vtxWeight = cmds.skinPercent(skinCl, vtx, q=True, v=True)
#Get Weights with getAttr
vtxWeight2 = []
for i in range(len(joints)):
w = cmds.getAttr('%s.weightList[%s].weights[%s]' % (skinCl, vtxID, str(i)))
vtxWeight2.append( w )
print 'Weights from skinPercent : ' + str(vtxWeight)
print 'Weights from weightList : ' + str(vtxWeight2)
print 'Weights are equal : ' + str(vtxWeight == vtxWeight2) # False !
This code gives me this log:
BindPose Try 1: None
BindPose Try 2: None
BindPose Try 3: [u’bindPose1’]
Weights from skinPercent : [0.0, 0.0, 0.0, 1.0, 0.0]
Weights from weightList : [0.0, 0.0, 0.0, 0.0, 1.0]
Weights are equal : False
- I have shorten the weight lists result