Sunday, July 17, 2011

Zero out selected ctrls

// Zeros out all Visible/Keyable Attributes On Selected Object(s)
// Author: Jay Grenier, 2010
// Last Update: May 6th, 2010
// Notes: Source script, select object, hit button. Or, make a shelf button that calls jgZeroOutAttrsDo For help email jay@jaygrenier.com


// **********************************************************
// Zeros out all Visible/Keyable Attributes On Select Object(s)
global proc jgZeroOutAttrsDo () {

// Get Selected
string $sel[] = `ls -sl` ;

// Loop
for($item in $sel) {

// Get All Attributes
string $attrs[] = `listAttr -v -k -s $item` ;

// Zero Out (Not Visibility or Scale)
for ($attr in $attrs) {
if($attr != "visibility" && $attr != "scaleX" && $attr != "scaleY" && $attr != "scaleZ") {

string $path = ($item+"."+$attr) ;
if(!`getAttr -l $path`) setAttr ($item+"."+$attr) 0 ;

}

}

}

}


// **********************************************************
// Zero Out GUI
global proc jgZeroOutAttrs () {

// Delete and Prefs
if (`window -exists jgZeroOutWin`) {
deleteUI jgZeroOutWin;
windowPref -removeAll jgZeroOutWin ;
}

//Define basic window specs
window
-w 100
-rtf true
-t ""
jgZeroOutWin ;

columnLayout
-adjustableColumn true
-rowSpacing 6
-columnOffset both 6;

button
-h 30
-bgc .75 .905 1
-l "Zero Out"
-c "jgZeroOutAttrsDo ;" ;

showWindow jgZeroOutWin ;

} jgZeroOutAttrs ;

No comments:

Post a Comment