Skip to content

Instantly share code, notes, and snippets.

@Neill3d
Created September 1, 2013 09:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neill3d/6403208 to your computer and use it in GitHub Desktop.
Save Neill3d/6403208 to your computer and use it in GitHub Desktop.
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