proc na_pickErrorCheck(string $joint, string $ik_joint, string $fk_joint, string $nameNode, string $control,string $attr)
{
//already made the connection
if(`objExists $nameNode` == 1){ error("Sorry, Already Connected--"+$nameNode); }
//missing on scene
if(`objExists $joint` == 0){ error("Sorry, Cannot find--"+$joint); }
if(`objExists $fk_joint` == 0){ error("Sorry, Cannot find--"+$fk_joint); }
//attribute what were expecting
if(`attributeExists $attr $control` == 0){ error("attribute: "+$attr+" for--"+$control+" not found");}
if( `attributeQuery -enum -node $control $attr` == 0){error("Expecting an Attribute of Type Enum");};
}
proc na_pickSuccess()
{
print("Created Connections");
}
/**
@param string $joint
@param string $ik_joint
@param string $fk_joint
@param string $type ex: translate or rotate
@param string $control -- what is used by animator to switch
@param string $attr -- attribute animator uses to switch
@param string $nodePrefix -- prefix for blend node
*/
global proc na_pick(string $joint, string $ik_joint, string $fk_joint, string $type,string $control, string $attr, string $nodePrefix){
//error check
na_pickErrorCheck( $joint,$ik_joint,$fk_joint,($nodePrefix+"_"+$type+"_blend"),$control, $attr);
//setting some variables
string $attribute[] = {($type+"X"),($type+"Y"),($type+"Z")};
string $nameNode = $nodePrefix+"_"+$type+"_blend";
string $animatorAttr = $control+"."+$attr; //should be able to make two choices only
string $pickArray[] = {"color2","color1"}; // assumes fk is 0 enum, and ik is 1 enum
string $blend_arg="";
//make node, this will stay on animator scene for life of rig
//
createNode blendColors -n $nameNode;
////now we can use ik rotation on our arm hand joint
//
$pick = $pickArray[0];
$blend_arg = $nameNode+"."+$pick;
connectAttr -f ($ik_joint+"."+$attribute[0]) ($blend_arg+"R");
connectAttr -f ($ik_joint+"."+$attribute[1]) ($blend_arg+"G");
connectAttr -f ($ik_joint+"."+$attribute[2]) ($blend_arg+"B");
////now we can use fk rotation on our arm hand joint
//
$pick = $pickArray[1];
$blend_arg = $nameNode+"."+$pick;
connectAttr -f ($fk_joint+"."+$attribute[0]) ($blend_arg+"R");
connectAttr -f ($fk_joint+"."+$attribute[1]) ($blend_arg+"G");
connectAttr -f ($fk_joint+"."+$attribute[2]) ($blend_arg+"B");
//now we can use either ik or fk rotation on our arm hand joint
//
connectAttr -f $animatorAttr ($nameNode+".blender");
connectAttr -f ($nameNode+".output"+"R") ($joint+"."+$attribute[0]);
connectAttr -f ($nameNode+".output"+"G") ($joint+"."+$attribute[1]);
connectAttr -f ($nameNode+".output"+"B") ($joint+"."+$attribute[2]);
na_pickSuccess();
}