I’m writing a tool to copy weights from the closest vertex and apparently it seems to work fine, the weights on both vertices are the same in the component editor, but when I move the joints, the vertices don’t have the same deformation.
If I save the weights, freeze and reload weights after this, it works fine.
What am I doing wrong?
The code is a little long, so I’m pasting only the important part:
#Copy weights from obj1 to obj0 selected vertices
#obj0 = object of the selected vertices
#obj1 = source of the weights
#selVtx = selected vertices (from obj0)
#skinCl0 = obj0 SkinCluster
#skinCl1 = obj1 SkinCluster
if skinCl0:
cmds.setAttr('%s.envelope' % skinCl0, 0)
if skinCl1:
cmds.setAttr('%s.envelope' % skinCl1, 0)
cmds.setAttr('%s.nw' % skinCl0, 0)
for id in range(len(selVtx)):
#closestVertID = Closest Vertex ID
cmds.move( vtxPos1[closestVert][0], vtxPos1[closestVert][1], vtxPos1[closestVert][2], selVtx[id], ws=True)
#Get obj1 weight
obj1Vtx = str(obj1)+'.vtx['+ str(closestVertID) +']'
compWeight = cmds.skinPercent(skinCl1, obj1Vtx, q=True, v=True)
vtx1Weight = zip(joints1, compWeight)
#Copy to obj0 vtx
cmds.skinPercent(skinCl0, selVtx[id], nrm=False, prw=100)
cmds.skinPercent(skinCl0, selVtx[id], nrm=False, r=False, tv=vtx1Weight)
cmds.setAttr('%s.envelope' % skinCl0, 1)
cmds.setAttr('%s.envelope' % skinCl1, 1)
From what I can see it is the move command. When I move the vertices, the deformation doesn’t work as expected.
[EDIT]
I just discovered that this happens even if I move weighted points manually (not scripting). Is this normal in Maya?