Monday 23 May 2016

align control to joint script.

global proc cly_orientControlToJoint() {

// selections and error checking
string $jointInQuestion[] = `ls -sl -fl -type "joint"`;
if (`size( $jointInQuestion )` != 1 ) {
error "cly_orientControlToJoint requires that only \"one\" joint be selected before running";
}
string $victims[] = `ls -sl -objectsOnly`;
string $controlSelections[] = stringArrayRemove ( $jointInQuestion, $victims );
if (`size( $controlSelections )` < 1 ) {
error "cly_orientControlToJoint requires that at least one object for alignment, must be selected before running";
}
// selections and error checking end

float $jointPositionValue[] = `xform -q -ws -t $jointInQuestion[0]`;

//aim control and zero out rotation values by burying in a group ( target objects aligned and zeroed )
for ( $c in $controlSelections ) {
string $cGrpName = $c+ "RotateGrp";
string $cGrp = `group -name $cGrpName $c`; // because zero rotation "home" values are good when animating
xform -ws -t $jointPositionValue[0] $jointPositionValue[1] $jointPositionValue[2] $cGrp; // align the group not the object
string $aim[] = `parentConstraint $jointInQuestion[0] $cGrp`;
delete $aim; // clean
makeIdentity -apply true -t 1 -r 1 -s 0 -n 0 $c; // zero possible transforms // to do: preference
}
select -r $victims;
}

Wednesday 11 May 2016

selection set maths. whoop

string $subtractionSet[]=`sets -subtract tipMid tips`;
select $subtractionSet;
sets -n mids;
select mids;