Copy Weights problem


#1

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?


#2

Found the solution.

Converting my vertex position to local and using move with relative fixed my problem. I still don’t understand why it doesn’t work in absolute or world space.

[EDIT]

Apparently this problem only occurs in 2015 and previous versions.
If “Retain component spacing” is unchecked, the points don’t deform as expected after they are moved. This happen doing it manually or by script (not using move with relative).

In 2016 it seems to work fine.

Is this a bug that was fixed in 2016?