MEL how to specify the skin weight value of a joint

To set the weight of a specific bone in Maya simply use skinPercent:

string $jointName = "jointxxx";
string $skinClusterName = "skinclusterxxx";
string $mesh = "pMyGeometryxxx";

    -transformValue /*name:*/$jointName/*skinWeight value:*/1.0 
    /*skin cluster node: */$skinClusterName

You can also manually specify the subset of vertices you wish to assign new skin weights to:

skinPercent -transformValue "joint_name" 1.0  
            "skinCluster29" pPlane1.vtx[2121] pPlane1.vtx[1748:2898] ;

Or just rely on the current selection (mesh, or set of vertices) by not specifying anything:

skinPercent -transformValue "joint_name" 1.0  

Alternate hack

To reset the influence (joint) of a skincluster to zero with a MEL command you can also use the trick below as an alternative to the skinPercent command:

    -removeInfluence $jointName $skinClusterName;

    -weight 0.0 
    -addInfluence $jointName $skinClusterName;

Issues when setting skin weights to 0

Keep in mind that setting a joint to zero may leave a vertex without any joint influencing it. In this case, this will produce incorrect deformation (most likely the vertices will collapse into the origin). The only way around this, is to code your own skin weight removal procedure to handle this specific case. You would have an algorithm to search for the nearest joint that could influence the vertices left without influencing joints. What "nearest" means is left for you to define...

Because built in brush tools in Maya do not gracefully handle skin weight removal (setting to 0), it is usually advised to use the so called "additive skinning" workflow. In additive skinning you forbid yourself to reduce or set to zero the value value of a joint, instead, you would strengthen (adding skin weights) of other joints until their influence overwhelms the influence of the joint you wish to weaken or erase. In additive skinning you never think: "this joint is influencing too much this part of my model", instead, you think "Those joints are not influencing enough this part of the mesh".

No comments

(optional field, I won't disclose or spam but it's necessary to notify you if I respond to your comment)
All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Anti-spam question: