Friday, March 7, 2014

Tip: MEL to select joints useful for skeleton binding

Happy Friday,

I found it helpful to use scripting to deselect joints we don't want to bind to our character.
Example if all the end joints have a name with suffix "_end" we can do something like this after we select all joints in hierarchy.



 //in MEL script editor
select -tgl "*_end" //deselects all end joints from all the things currently selected



It may be helpful in skinning to select all joints from the selected root... Here is a short MEL script i wrote to do that .. (it also works if say wanted to select all arm joints just need to select the shoulder of each arm then run the script to select all the joints)


global proc na_selJointInHierarchyFromSelectedRoot(){
//---select all joints in hierarchy of selected root
string $sel[] = `ls -sl`;
if(size($sel) == 1){
    select -hierarchy; select -r `ls -sl -type joint`;
}
else{
warning("Treating Each thing selected as a Root !!!\n");
//error("Requires a single selected root !!!\n");
string $addToSel[] = {};
for($arg in $sel){
    select -r $arg;
    select -hierarchy; select -r `ls -sl -type joint`;
    $addToSel = stringArrayCatenate($addToSel, `ls -sl`);
    select -cl;
}
$addToSel = stringArrayRemoveDuplicates($addToSel);
select -r $addToSel;
 }
}
na_selJointInHierarchyFromSelectedRoot();




Hope you find this helpful.
cheers,
-Nate


Inspired by
Carlo Sansonetti (carlosansonetti dot com)