Thursday, September 25, 2008

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;
}
}

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home