Monday, July 15, 2013

Tips: MEL for renaming and selecting

Hi there,

These are a couple short scripts I wrote today that helped me rename stuff and select stuff.  Hope you find them helpful.

//rename lots of selected joints assumes ordering selection okay
string $rigPart = "head";
string $sel[] = `ls -sl`;
for($i = 0; $i < size($sel); $i++){
string $arg = $sel[$i];
rename $arg ($rigPart+"_"+($i+1)+"_joint");
}


//parent lots of geo to joints by name, doesnt need a selection
string $rigPart = "head";
select ($rigPart+"*geo");
string $sel[] = `ls -sl`;
for($i = 0; $i < size($sel); $i++){
string $arg = ($rigPart+"_"+($i+1)+"_geo");
parent $arg ($rigPart+"_"+($i+1)+"_joint");
};



//---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{ error("Requires a single selected root !!!\n"); }

//selecting lots of stuff by name
select "*palm_*" 

cheers,
-Nate