Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MEL Script for reseting skin bind pose.
//
// Reset bind pose for selected mesh with skin cluster
//
// it will copy object, bind with the same weights, copy weights, delete old object
//
// Author Sergey Solohin (Neill3d) 2013, e-mail to: s@neill3d.com
// www.neill3d.com
//
string $selection[] = `ls -sl`;
for ($obj in $selection)
{
select -r $obj;
string $newObj[] = `duplicate -smartTransform`;
//-- get list of skin joints
string $jointsList[] = `skinCluster -q -inf $obj`;
select -r $jointsList;
select -cl;
for ($s in $jointsList)
if (nodeType($s) == "joint")
select -add $s;
select -add $newObj;
// bind skin cluster
string $newSkinCluster[] = `skinCluster -tsb -mi 4`;
// add all other influences
for ($s in $jointsList)
if (nodeType($s) != "joint")
{
//string $relatives[] = `listRelatives -shapes $s`;
//string $objShape = $relatives[0];
select -r $newObj;
skinCluster -e -ug -ai $s;
}
setAttr ($newSkinCluster[0] + ".useComponents") 1;
// copy skin weights
select -r $obj;
select -add $newObj;
copySkinWeights -noMirror -surfaceAssociation closestComponent -influenceAssociation name;
// delete old object and rename a new one
delete $obj;
rename $newObj $obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.