Tuesday, October 7, 2008

WalkCycle



I made this walk cycle as an animation test of my IKFK Rig, which works quite well, if I might say so myself. :)

The actual anim is only 25 frames long, but completely loopable, as shown.

Labels: ,


Read more!

Thursday, September 25, 2008

IK/FK Switch

This first script is incredibly helpful in animation. It's a script that will allow for IK/FK switching on a character rig with a single skeleton. This switch works without popping, or any other wonky, unwanted movement. It also keeps your rig clean without having to set up 3 skeletons that drive each other and make for a very confusing rig.
I based this script off of one I found online written by Lionel Gallant, but I modified it pretty heavily to work on my own, procedurally generated rig. I'm only including the arms to save some space, but it does work for legs as well, or anything else the animator would need it for with a little bit of tweaking.



// ==============================================================
// Turn arm IK on or off while preserving the arm orientation.
// ==============================================================
// This script will switch between IK and FK states on the arms
// and legs without any popping in the animation.
// Based on a script originally written by Lionel Gallat.

global proc IkFk_switch( string $side, string $limb )
{
string $rigName = getSelectedRigName();
string $rigSideName = ($rigName + ":" + $side);

string $currentSelection[] = `ls -sl`;

// Check to see if anything is keyed in the arm, and if so, set the flag.
int $keyWhenSwitching = 0;

// Declaring arm variables.
float $keysOnShoulder[] = `keyframe -q ($rigSideName + "Shoulder")`;
float $keysOnShoulderControl[] = `keyframe -q ($rigSideName + "ShoulderControl")`;
float $keysOnElbow[] = `keyframe -q ($rigSideName + "Elbow")`;
float $keysOnElbowControl[] = `keyframe -q ($rigSideName + "ElbowControl")`;
float $keysOnArmIk[] = `keyframe -q ($rigSideName + "ArmIKControl")`;
float $keysOnArmPole[] = `keyframe -q ($rigSideName + "armPV")`;
float $keysOnShoulderConstraint[] = `keyframe -q ($rigSideName + "Shoulder_orientConstraint1")`;
float $keysOnElbowConstraint[] = `keyframe -q ($rigSideName + "Elbow_orientConstraint1")`;


if ( `size $keysOnShoulder` != 0 ||
`size $keysOnElbow` != 0 ||
`size $keysOnArmIk` != 0 ||
`size $keysOnArmPole` != 0 ||
`size $keysOnShoulderControl` != 0 ||
`size $keysOnElbowControl` != 0 ||
`size $keysOnShoulderConstraint` != 0 ||
`size $keysOnElbowConstraint` != 0 )

{
$keyWhenSwitching = 1;
}
// ----------------
// Turn arm IK off.
// ----------------

if ( $limb == "arm" )
{
if ( `getAttr ( $rigSideName + "ArmIKControl.enableIk")` == 1 )
{
// Get current arm joints rotation info.
vector $shoulderRot = `xform -q -r -ro ($rigSideName + "Shoulder")`;
vector $elbowRot = `xform -q -r -ro ($rigSideName + "Elbow")`;
vector $shoulderLoc = `xform -q -r -ro ($rigSideName + "ShoulderLoc")`;
vector $elbowLoc = `xform -q -r -ro ($rigSideName + "ElbowLoc")`;

// Disable the IK solver (if there are keys on the joints, the arm will pop back to those).
setAttr ($rigSideName + "ArmIKControl.enableIk") 0;

// Match the joints rotations.
setAttr ($rigSideName + "Shoulder.rx") ($shoulderRot.x);
setAttr ($rigSideName + "Shoulder.ry") ($shoulderRot.y);
setAttr ($rigSideName + "Shoulder.rz") ($shoulderRot.z);
setAttr ($rigSideName + "Elbow.ry") ($elbowRot.y);
setAttr ($rigSideName + "ShoulderControl.rx") ($shoulderLoc.x);
setAttr ($rigSideName + "ShoulderControl.ry") ($shoulderLoc.y);
setAttr ($rigSideName + "ShoulderControl.rz") ($shoulderLoc.z);
setAttr ($rigSideName + "ElbowControl.ry") ($elbowLoc.y);

// Make the controls visible again, and enable the constraints.
setAttr ($rigSideName + "ShoulderControl.visibility") 1;
setAttr ($rigSideName + "ElbowControl.visibility") 1;
setAttr ($rigSideName + "Shoulder_orientConstraint1." + $side + "ShoulderControlW0" ) 1;
setAttr ($rigSideName + "Elbow_orientConstraint1." + $side + "ElbowControlW0" ) 1;

// If there are keys anywhere on the arm, then key the shoulder and elbow, and then delete the constraint.
if ( $keyWhenSwitching )
{
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "ShoulderControl");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "Shoulder");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "ElbowControl");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "Elbow");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "ArmIKControl");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "armPV");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "Shoulder_orientConstraint1");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "Elbow_orientConstraint1");
}
}

// ---------------
// Turn arm IK on.
// ---------------
else
{
// Move the IK control to the current position of the wrist.
pointConstraint -w 1 -o 0 0 0 ($rigSideName + "Wrist") ($rigSideName + "ArmIKControl");

// If there are keys anywhere on the arm, then key the armIk and delete the constraint.
if ( $keyWhenSwitching )
{
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "ArmIKControl");
}
delete ($rigSideName + "ArmIKControl_pointConstraint1");

// Move the pole vector where it should be to match the arm angle.
pointConstraint -w 1 -o 0 0 0 ($rigSideName + "armLoc") ($rigSideName + "armPV");

// If there are keys anywhere on the arm, then key the armPole and delete the constraint.
if ( $keyWhenSwitching )
{
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "armPV");
}
delete ($rigSideName + "armPV_pointConstraint1");

// Bring the IKHandle to the control point.
pointConstraint -w 1 -o 0 0 0 ($rigSideName + "ArmIKControl") ($rigSideName + "armIKHandle");
delete ($rigSideName + "armIKHandle_pointConstraint1");

// Set the constraint weights to zero.
setAttr ($rigSideName + "Shoulder_orientConstraint1." + $side + "ShoulderControlW0" ) 0;
setAttr ($rigSideName + "Elbow_orientConstraint1." + $side + "ElbowControlW0" ) 0;


// Turn the Visibility of the FK controls off.
setAttr ($rigSideName + "ShoulderControl.visibility") 0;
setAttr ($rigSideName + "ElbowControl.visibility") 0;

// Enable the IK solver.
setAttr ($rigSideName + "ArmIKControl.enableIk") 1;

// If there are keys anywhere on the arm, then key the shoulder and elbow, and then delete the constraint.
if ( $keyWhenSwitching )
{
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "ShoulderControl");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "Shoulder");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "ElbowControl");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "Elbow");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "ArmIKControl");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "armPV");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "Shoulder_orientConstraint1");
setKeyframe -breakdown 0 -hierarchy none -controlPoints 0 -shape 1 ($rigSideName + "Elbow_orientConstraint1");
}
}
}
}


Read more!

AnimationTraxUI

This is a helpful little UI that will allow the animator keep multiple animations organized within a single maya file. It saves the name of the animation, and the start and end time, and automatically adjusts the time slider to match the times of the anim after being set by the animator. It also has an export function to export the selected anim to a .anim file.



//This UI will set up a UI to manage note tracks for animations.

global proc AnimationTraxUI ()
{
//initial window setup
if (`window -exists AnimationTraxUI`)
deleteUI AnimationTraxUI;

window
-t "Animation Trax"
-wh 500 325
-mxb off
-resizeToFitChildren on
-sizeable off
AnimationTraxUI;

columnLayout -adj 1 imageCol;
string $baseImageDir = `getenv "ACOOK_SCRIPT_PATH"` + "/Icons/AnimationTraxUI/";
image -w 500 -h 20 -image ($baseImageDir + "logo.tif");

separator -w 500 -style "in";

formLayout animForm;
//content start
text -l "Animations:" animText;
text -l "Notes:" noteText;

textScrollList -h 150 TSLanims;
textScrollList -h 150 TSLnotes;

button -l "New Anim" -command "addNewAnim" newAnimButton;
button -l "Start Time" -command "addStartTime" startAnimButton;
button -l "End Time" -command "addEndTime" endAnimButton;
button -l "Event" -command "eventTrigger" eventButton;
button -l "Export" -command "export" exportAnimButton;

popupMenu -parent TSLanims;
menuItem -l "Delete Anim" -command "deleteAnim ()";
popupMenu -parent TSLnotes;
menuItem -l "Delete Note";
//content end

//UI layout formation
formLayout -e
-af animText top 0
-af animText left 0
-ap animText right 0 45

-af noteText top 0
-ac noteText left 0 animText
-af noteText right 0

-ac TSLanims top 0 animText
-af TSLanims left 0
-ap TSLanims right 0 45

-af TSLnotes right 0
-ac TSLnotes top 0 noteText
-ac TSLnotes left 2 TSLanims
-aoc TSLnotes bottom 0 TSLanims

-ac newAnimButton top 5 TSLanims
-af newAnimButton left 0
-ap newAnimButton right 0 45

-ac startAnimButton top 5 TSLnotes
-ac startAnimButton left 2 newAnimButton
-ap startAnimButton right 0 63

-ac endAnimButton top 5 TSLnotes
-ac endAnimButton left 0 startAnimButton
-ap endAnimButton right 0 81

-ac eventButton top 5 TSLnotes
-ac eventButton left 0 endAnimButton
-ap eventButton right 0 100

-af exportAnimButton left 20
-ac exportAnimButton top 5 newAnimButton
-ap exportAnimButton right 0 40

animForm;

separator -w 500 -style "in";

setParent imageCol;
string $collapse = "window -e -h 295 AnimationTraxUI";
string $expand = "window -e -h 500 AnimationTraxUI";

frameLayout -collapsable 1
-label "Help"
-collapse on
-borderStyle "etchedIn"
-marginHeight 2
-marginWidth 2
-collapseCommand $collapse
-expandCommand $expand
helpFrame;

columnLayout helpCol;

string $help;

$help = ("Start by clicking the New Anim Button, then select the frame you want that anim to start at"
+"and click Start Time.\n\nRepeat for the End time of the animation.\n"
+"Create the start frame first, otherwise when you create the start frame it will overwrite your first note.\n"
+"Add events in the middle of the animation the same way as the start and end time.\n\n"
+"To delete an animation or note, simply right click on the anim or note and "
+"select 'Delete Anim' or 'Delete Note.'\nThis functionality will be implemented soon.\n\n"
+"Any questions, comments, or suggestions \nemail me at jalek_99@yahoo.com.\n\n"
+"Thanks,\n"
+"Andrew Cook");

scrollField
-ed false
-wordWrap true
-text $help
-w 492
-h 200
helpScrollField;
//End of Layout Formation

showWindow AnimationTraxUI;

FillAnims;

}

global proc FillAnims()
{
string $animNameString[] = `fileInfo -q SavedAnimations`;
string $animNames[];
$animNames = stringToStringArray( $animNameString[0], "|" );

if (size($animNames) == 0)
print "Please create an animation.\n";
else
{
string $selAnim[] = `textScrollList -q -si TSLanims`;
string $allAnims[] = `textScrollList -q -ai TSLanims`;
string $allNotes[] = `textScrollList -q -ai TSLnotes`;
string $newStartTimeName = "Start";
textScrollList -e -ra TSLanims;
// Fill the animation scroll list with the animation names
for ($eachAnim in $animNames)
{
textScrollList -e
-append $eachAnim
-si $animNames[0]
-sc "AnimSelected"
TSLanims;
}
/*
for ($eachNote in $allNotes)
{
textScrollList -e -append $eachNote TSLnotes;
}
textScrollList -e -si $newStartTimeName TSLnotes; */
// Call NoteSelected if it doesn't automatically get called
fillNotes();
}
}

//Populate the Notes TSL

global proc fillNotes()
{
string $allNotes[] = `textScrollList -q -ai TSLnotes`;
string $selAnim[] = `textScrollList -q -selectItem TSLanims`;
textScrollList -e -ra TSLnotes;

string $varName = $selAnim[0] + ".Events";
string $animEventsString[] = `fileInfo -q $varName`;
string $animEvents[] = stringToStringArray( $animEventsString[0], "|" );

for ( $eachEvent in $animEvents )
{
string $eventNames[] = stringToStringArray( $eachEvent, "." );
int $i = 1;
string $eventName = "";
for ( $i; $i <> 1 )
{
$eventName = $eventName + ".";
}
$eventName = $eventName + $eventNames[$i];
}
textScrollList -e -append $eventName TSLnotes;
}

textScrollList -e
-selectItem "Start"
-sc "NoteSelected"
TSLnotes;
}

//----------------------------
// Add new anim

global proc addNewAnim ()
{
string $newAnimName;
string $newAnim;

string $result = `promptDialog
-title "New Anim"
-message "Enter New Anim Name:"
-button "Ok" -button "Cancel"
-defaultButton "Ok" -cancelButton "Cancel"
-dismissString "Cancel"`;

string $allAnims[] = `textScrollList -q -ai TSLanims`;

if ($result == "Ok")
{
$newAnimName = `promptDialog -query -text`;
$newAnim = $newAnimName;
$allAnims[size($allAnims)]=$newAnim;
$allAnims=sort($allAnims);
string $allAnimsString = stringArrayToString( $allAnims, "|" );
fileInfo SavedAnimations $allAnimsString;


textScrollList -e -ra TSLanims;

for ($eachAnim in $allAnims)
textScrollList -e -a $eachAnim TSLanims;
//select the just created Anim.
textScrollList -e -si $newAnim TSLanims;
//also, clear the note track for the new anim.
textScrollList -e -ra TSLnotes;
textScrollList -e -selectCommand "AnimSelected ()" TSLanims;
}
else if (size($allAnims) > 0)
{
textScrollList -e -si $allAnims[0] TSLanims;
}
else
{
print "Please create an animation.\n";
}
}

//----------------------------
// Add Start Time for selected anim

global proc addStartTime ()
{
string $selAnim[] = `textScrollList -q -si TSLanims`;
string $allAnims[] = `textScrollList -q -ai TSLanims`;
string $allNotes[] = `textScrollList -q -ai TSLnotes`;

string $newStartTimeName = "Start";
int $newStartTime;

string $result = `confirmDialog
-title "Start Time"
-message "Create or Move start time to the selected frame?"
-button "Ok" -button "Cancel"
-defaultButton "Ok"
-cancelButton "Cancel"
-dismissString "Cancel"`;

if ($result == "Ok")
{
$newStartTime = `currentTime -query`;
playbackOptions -min $newStartTime;

string $startVariableName = $selAnim[0] + "." + $newStartTimeName;
fileInfo $startVariableName $newStartTime;
//add NewStartTime to the TOP of the list
$allNotes[0] = $newStartTimeName;
//clear TSLnotes for repopulation
textScrollList -e -ra TSLnotes;
//repopulate TSLnotes
for ($eachNote in $allNotes)
textScrollList -e -append $eachNote TSLnotes;
textScrollList -e -si $newStartTimeName TSLnotes;
}
saveEventNames();
}

//----------------------------------
// Add End Time

global proc addEndTime ()
{
string $selAnim[] = `textScrollList -q -si TSLanims`;
string $allAnims[] = `textScrollList -q -ai TSLanims`;
string $allNotes[] = `textScrollList -q -ai TSLnotes`;

string $newEndTimeName = "End";
int $newEndTime;

string $result = `confirmDialog
-title "Start Time"
-message "Create or Move End time to the selected frame?"
-button "Ok" -button "Cancel"
-defaultButton "Ok"
-cancelButton "Cancel"
-dismissString "Cancel"`;

if ($result == "Ok")
{
$newEndTime = `currentTime -query`;
playbackOptions -max $newEndTime;

// Save the end time variable to the scene
string $endVariableName = $selAnim[0] + "." + $newEndTimeName;
fileInfo $endVariableName $newEndTime;
if (size($allNotes) > 1)
{
//if there is an end note, change it.
$allNotes[size ($allNotes) - 1] = $newEndTimeName;
}
else
{
//or add it if there isn't one.
$allNotes[size ($allNotes)] = $newEndTimeName;
}

//clear TSLnotes for repopulation
textScrollList -e -ra TSLnotes;

//repopulate TSLnotes
for ($eachNote in $allNotes)
textScrollList -e -append $eachNote TSLnotes;
textScrollList -e -si $newEndTimeName TSLnotes;
}
saveEventNames();
}

//-------------------------------------
//Proc for when a note is selected in the window
global proc NoteSelected ()
{
string $selAnim[] = `textScrollList -q -si TSLanims`;
string $selNote[] = `textScrollList -q -si TSLnotes`;
string $allNotes[] = `textScrollList -q -ai TSLnotes`;

if (size($allNotes) > 0)
{
string $varName = ($selAnim[0] + "." + $selNote[0]);
string $variableValue[] = `fileInfo -q $varName`;
currentTime $variableValue[0];
}
// else print "Please create a start and end time for the animation.\n";
}

//------------------------------------
// Proc for when an anim is selected in the window

global proc AnimSelected ()
{
string $selAnim[] = `textScrollList -q -si TSLanims`;
string $selNote[] = `textScrollList -q -si TSLnotes`;
string $allNotes[] = `textScrollList -q -ai TSLnotes`;

string $varName = ($selAnim[0] + "." + $selNote[0]);
string $variableValue[] = `fileInfo -q $varName`;

textScrollList -e -si $allNotes[0] TSLnotes;

$varName = ($selAnim[0] + ".Start");
string $startTime[] = `fileInfo -q $varName`;
playbackOptions -min $startTime[0];

$varName = ($selAnim[0] + ".End");
string $endTime[] = `fileInfo -q $varName`;
playbackOptions -max $endTime[0];

fillNotes;
NoteSelected;

if (size($allNotes) == 0)
print "Please create a start and end time for the selected animation.\n";


}

//---------------------------------------------------
// Create an Event Trigger
// This functionality will be added as needed,
// for the time being it will just add an event marker to the current time.

global proc eventTrigger ()
{
string $selAnim[] = `textScrollList -q -si TSLanims`;
string $allAnims[] = `textScrollList -q -ai TSLanims`;
string $allNotes[] = `textScrollList -q -ai TSLnotes`;
float $currentTime = `currentTime -q`;

string $newEventTimeName = ("Event." + $currentTime);
int $newEventTime;

string $result = `confirmDialog
-title "Start Time"
-message "Create an event at the selected frame?"
-button "Ok" -button "Cancel"
-defaultButton "Ok"
-cancelButton "Cancel"
-dismissString "Cancel"`;

if ($result == "Ok")
{
$newEventTime = `currentTime -query`;

// Save the end time variable to the scene
string $eventVariableName = $selAnim[0] + "." + $newEventTimeName;
fileInfo $eventVariableName $newEventTime;
if (size($allNotes) >! 2)
{
//if there is an end note, change it.
$allNotes[size ($allNotes)] = $allNotes[size ($allNotes)-1];
$allNotes[size ($allNotes)-2] = $newEventTimeName;

//clear TSLnotes for repopulation
textScrollList -e -ra TSLnotes;

//repopulate TSLnotes
for ($eachNote in $allNotes)
{
print ("Note: " + $eachNote + "\n" );
textScrollList -e -append $eachNote TSLnotes;
}
textScrollList -e -si $newEventTimeName TSLnotes;
}
else
{
print "Please create a start and end time first.\n";
}
}
saveEventNames();
}

global proc saveEventNames()
{
string $allEvents[] = `textScrollList -q -ai TSLnotes`;
string $selectedAnim[] = `textScrollList -q -si TSLanims`;
int $i = 0;
for ( $i; $i < size( $allEvents ); $i++ )
{
$allEvents[$i] = $selectedAnim[0] + "." + $allEvents[$i];
}
string $allEventsString = stringArrayToString( $allEvents, "|" );
string $varName = $selectedAnim[0] + ".Events";
fileInfo $varName $allEventsString;
}

//------------------------------------------------
// This is setup to export generic .anim files at the moment.

global proc export()
{
string $folderToSaveTo = `fileDialog -m 1`;
string $fileName = `file
-typ "animExport"
-pr
-es ($folderToSaveTo)`;
print ($fileName + "\n");
}

//-------------------------------------------------
//This will delete the selected anim.
global proc deleteAnim ()
{
string $savedAnimList[] = `fileInfo -q SavedAnimations`;
string $savedAnims[] = stringToStringArray( $savedAnimList[0], "|");
string $selectedAnim[] = `textScrollList -q -si TSLanims`;
string $allAnims[] = `textScrollList -q -ai TSLanims`;
int $i = 0;
for ( $i; $i < size( $savedAnims ); $i++ )
{
if ($savedAnims[$i] == $selectedAnim[0])
{
string $currentAnim[] = stringToStringArray( $savedAnims[$i], "");
string $newAnimList[] = stringArrayRemove($currentAnim, $savedAnims);
$savedAnims = $newAnimList;
string $newSaveAnimList = stringArrayToString ($savedAnims, "|");
fileInfo SavedAnimations $newSaveAnimList;
textScrollList -e -ri $selectedAnim[0] TSLanims;
textScrollList -e -ra TSLnotes;
textScrollList -e -si $allAnims[0] TSLanims;
AnimSelected;
}
}
}


Read more!

CleanupControls


This is a smaller script which allows for quick cleanup of a file. It includes Locking and Hiding attributes, Freezing transforms and deleting history all at the click of a button.







//=================================================================

global proc ac_animControlCleanUpUI ()
{
if (`window -exists ac_animControlCleanUpUI`)
deleteUI ac_animControlCleanUpUI;

window -title ac_animControlCleanUpUI
-widthHeight 222 485
-maximizeButton off
-minimizeButton off
-sizeable off
ac_animControlCleanUpUI;

columnLayout -adj 1 mainColumn;

string $baseImageDir = `getenv "ACOOK_SCRIPT_PATH"` + "/Icons/ac_animControlCleanupUI/";
image -w 220 -h 20 -image ($baseImageDir + "title.jpg");
separator -w 220 -h 6 -vis 1 -st "in";
image -w 220 -h 20 -image ($baseImageDir + "LockUnlock.jpg");
// Lock/Unlock Frame
frameLayout -l " "
-collapsable on
-collapse off
-borderStyle "etchedIn"
-marginHeight 2
-marginWidth 2
lockFrame;

rowColumnLayout -numberOfColumns 2 lockRCL;

button -l "Translate" -w 130 -command "lockTranslate ()" lockTransButton;
button -l "Translate" -w 130 -command "unlockTranslate ()" unlockTransButton;
button -l "Rotate" -w 130 -command "lockRotate ()" lockRotButton;
button -l "Rotate" -w 130 -command "unlockRotate ()" unlockRotButton;
button -l "Scale" -w 130 -command "lockScale ()" lockScaleButton;
button -l "Scale" -w 130 -command "unlockScale ()" unlockScaleButton;


setParent mainColumn;
separator -w 220 -h 6 -vis 1 -st "in";
image -w 220 -h 20 -image ($baseImageDir + "KeyUnkey.jpg");
// Key/Unkey Frame
frameLayout -l " "
-collapsable on
-collapse off
-borderStyle "etchedIn"
-marginHeight 2
-marginWidth 2
keyFrame;

rowColumnLayout -numberOfColumns 2 keyRCL;
button -l "Translate" -w 130 -command "unkeyableTranslate ()" unkeyTransButton;
button -l "Translate" -w 130 -command "keyableTranslate ()" keyTransButton;
button -l "Rotate" -w 130 -command "unkeyableRotate ()" unkeyRotButton;
button -l "Rotate" -w 130 -command "keyableRotate ()" keyRotButton;
button -l "Scale" -w 130 -command "unkeyableScale ()" unkeyScaleButton;
button -l "Scale" -w 130 -command "keyableScale ()" keyScaleButton;


setParent mainColumn;

image -w 220 -h 20 -image ($baseImageDir + "delHistory.jpg");
// Delete History Frame
frameLayout -l " "
-collapsable on
-collapse off
-borderStyle "etchedIn"
-marginHeight 2
-marginWidth 2
globalFrame;
rowColumnLayout -numberOfColumns 1 -columnWidth 1 200 delHisRCL;
button -l "Delete History" -w 200 -command "deleteHistory ()" delHisButton;

setParent mainColumn;

image -w 220 -h 20 -image ($baseImageDir + "freezeTransforms.jpg");
// Freeze Transforms Frame
frameLayout -l " "
-collapsable on
-collapse off
-borderStyle "etchedIn"
-marginHeight 2
-marginWidth 2
freezeFrame;
rowColumnLayout -numberOfColumns 1 -columnWidth 1 200 delHisRCL;
button -l "Translate" -w 200 -command "freezeTrans ()" freezeTransButton;
button -l "Rotate" -w 200 -command "freezeRot ()" freezeRotButton;
button -l "Scale" -w 200 -command "freezeScale ()" freezeScaleButton;

setParent mainColumn;

// Help Frame
string $collapseCmd = "window -e -h 485 ac_animControlCleanUpUI";
string $expandCmd = "window -e -h 739 ac_animControlCleanUpUI";

frameLayout -l "Help"
-collapsable on
-collapse on
-borderStyle "etchedIn"
-marginHeight 2
-marginWidth 2
-preExpandCommand $expandCmd
-preCollapseCommand $collapseCmd
helpFrame;

string $helpContent;
$helpContent = ("This script eases the pain of cleaning up character controls."
+ "\n"
+ "\n"
+ "The controls are self explanatory, "
+ "just select the node and click the button."
+ "\n"
+ "\n"
+ "Any problems, email me at jalek_99@yahoo.com"
+ "\n"
+ "\n"
+ "Andrew Cook");

scrollField -wordWrap true -height 250 -text $helpContent helpScroll;
setParent mainColumn;

showWindow ac_animControlCleanUpUI;
}


//===========================================================
// Lock/Unlock Procedures

global proc lockTranslate ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
setAttr -lock true ($each + ".tx");
setAttr -lock true ($each + ".ty");
setAttr -lock true ($each + ".tz");
}
}

global proc lockRotate ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
setAttr -lock true ($each + ".rx");
setAttr -lock true ($each + ".ry");
setAttr -lock true ($each + ".rz");
}
}

global proc lockScale ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
setAttr -lock true ($each + ".sx");
setAttr -lock true ($each + ".sy");
setAttr -lock true ($each + ".sz");
}
}

global proc unlockTranslate ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
setAttr -lock false ($each + ".tx");
setAttr -lock false ($each + ".ty");
setAttr -lock false ($each + ".tz");
}
}

global proc unlockRotate ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
setAttr -lock false ($each + ".rx");
setAttr -lock false ($each + ".ry");
setAttr -lock false ($each + ".rz");
}
}

global proc unlockScale ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
setAttr -lock false ($each + ".sx");
setAttr -lock false ($each + ".sy");
setAttr -lock false ($each + ".sz");
}
}

//===========================================================
// Key Procedures

global proc keyableTranslate ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
setAttr -keyable true ($each + ".tx");
setAttr -keyable true ($each + ".ty");
setAttr -keyable true ($each + ".tz");
}
}

global proc keyableRotate ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
setAttr -keyable true ($each + ".rx");
setAttr -keyable true ($each + ".ry");
setAttr -keyable true ($each + ".rz");
}
}

global proc keyableScale ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
setAttr -keyable true ($each + ".sx");
setAttr -keyable true ($each + ".sy");
setAttr -keyable true ($each + ".sz");
}
}

global proc unkeyableTranslate ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
setAttr -keyable false ($each + ".tx");
setAttr -keyable false ($each + ".ty");
setAttr -keyable false ($each + ".tz");
}
}

global proc unkeyableRotate ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
setAttr -keyable false ($each + ".rx");
setAttr -keyable false ($each + ".ry");
setAttr -keyable false ($each + ".rz");
}
}

global proc unkeyableScale ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
setAttr -keyable false ($each + ".sx");
setAttr -keyable false ($each + ".sy");
setAttr -keyable false ($each + ".sz");
}
}

//====================================================
// Delete Histroy Proc

global proc deleteHistory ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
delete -ch;
}
}

//====================================================
// Freeze Transform Procs

global proc freezeTrans ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
makeIdentity -apply true -t 1 -r 0 -s 0 -n 0;
}
}

global proc freezeRot ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
makeIdentity -apply true -t 0 -r 1 -s 0 -n 0;
}
}

global proc freezeScale ()
{
string $sel[] = `ls -sl`;

for ($each in $sel)
{
makeIdentity -apply true -t 0 -r 0 -s 1 -n 0;
}
}


Read more!