Tuesday, October 14, 2014

Select Cluster of Hierarchy (MEL), Create ik sc (MEL)

Hi,

Here are a couple scripts i wrote that are beginning to be useful in using mocap animation to preview some rigging deformation.

//select all cluster in all selected roots
//Author: Nathaniel Anozie (ogbonnawork at gmail dot com)
//nathananozie dot blogspot dot com
global proc na_selectClusterOfHierarchy(){
string $result[] = {};
string $sel[] = `ls -sl`;
for($arg in $sel){
string $past[] = {};
$past =`listConnections $arg`;
string $hist[] = `ls -type cluster $past`;//cluster history
if(size($hist) == 1){ $result = stringArrayCatenate($result, $hist);//save it
}else{}
}//end loop
$result = stringArrayRemoveDuplicates($result);
select -r $result;
}
na_selectClusterOfHierarchy();


//create ik sc use selected root, assumes has child
//inspired by Anop A.K (codecg dot com) learning about iksc drawing in mel
 
string $sel[] = `ls -sl`;
if(size($sel) == 1){
string $root = $sel[0];
select -r $root;
string $check[] =`listRelatives -children -type joint $root`;
if(size($check) != 1){ error("Error Nothing to Draw IK SC with, check end"); }
 
pickWalk -direction down;//using this so get full path
string $children[] = {};
$children = `ls -sl -type joint`;
if(size($children) != 1){print("Error Nothing to end IK SC at");}
else{
string $end = $children[0];
select -r $root $end; //make ik sc
ikHandle -sol ikRPsolver;
select -cl;
}
} 

Cheers,
Nate