////////////////////////// // // Maya script file // ////////////////////////// // // Author : Lluís Llobera // (lluisllobera@hotmail.com) // // Creation date : 30/IX/2003 // Update 1.5 : 30/VIII/2004 // Update 1.51 : 31/VIII/2004 // // Main procedure : type "llRotateOrder" in the Command Line or Script Editor // ////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // // This script will create a window to allow the user to quickly // change the rotation order of all the selected transform nodes. // // UPDATE 1.5 // // Now the buttons change, on selection change, to reflect the rotation order of the // currently selected objects. // // UPDATE 1.51 // // Thanks to macaroniKazoo for suggesting a very cool way to change the rotation order // and preserve the orientation of the objects at the same time ! :) // // // Enjoy!! // //////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// // llROColorButtons // ////////////////////////////////// // // This proc changes the background color flag on the // window buttons. // It is triggered by a selectionChange or a button press // on the main window. // // <-- llMakeRotateOrder // <-- llRotateOrder // ///////////////////////////////// global proc llROColorButtons () { vector $DEFAULTCOLOR = << 1.0 , 0.9 , 0.2 >> ; vector $ACTIVECOLORMAX = << 1.0 , 0.5 , 0.2 >> ; vector $ACTIVECOLORMIN = << 1.0 , 0.7 , 0.5 >> ; vector $NOCOLOR = << 0.75 , 0.75 , 0.75 >> ; vector $BUTTONCOLOR[] ; vector $CURRENTCOLOR ; int $MIXED = -1 ; int $ENABLE ; string $SELECTED [] = `ls -sl -type transform -type joint` ; int $ORDERS[] = { 0 , 0 , 0 , 0 , 0 , 0 } ; if (`size $SELECTED` != 0) { $ENABLE = 1 ; for ($I = 0 ; $I <= (`size $SELECTED`-1) ; $I++) { int $CURRENTORDER = eval ("getAttr " + $SELECTED[$I] + ".rotateOrder") ; $ORDERS[$CURRENTORDER] = $ORDERS[$CURRENTORDER] + 1 ; } ; // for for ($ORDER in $ORDERS) if ($ORDER > 0) $MIXED += 1 ; for ($I = 0 ; $I <= 5 ; $I++) { if ($ORDERS[$I] > 0) if ($MIXED > 0) $BUTTONCOLOR[$I] = $ACTIVECOLORMIN ; else $BUTTONCOLOR[$I] = $ACTIVECOLORMAX ; else $BUTTONCOLOR[$I] = $DEFAULTCOLOR ; } ; // for } // if (`size $SELECTED` != 0) else { $ENABLE = 0 ; for ($I = 0 ; $I <= 5 ; $I++) $BUTTONCOLOR[$I] = $NOCOLOR ; } ; // else for ($I = 0 ; $I <= 5 ; $I++) { $CURRENTCOLOR = $BUTTONCOLOR[$I] ; eval ("button -e -bgc " + ($CURRENTCOLOR.x) + " " + ($CURRENTCOLOR.y) + " " + ($CURRENTCOLOR.z) + " -en " + $ENABLE + " llROWB" + $I) ; eval ("button -e -vis 0 llROWB" + $I) ; eval ("button -e -vis 1 llROWB" + $I) ; } ; // for } ; // global proc llROColorButtons ////////////////////////////////// // llMakeRotateOrder // ////////////////////////////////// // // Depending on which button was pressed, // a different rotate order is set // for every selected transform node. // // --> llROColorButtons // ///////////////////////////////// global proc llMakeRotateOrder (string $ORDER) { int $I = 0 ; string $LIST[] = `ls -sl -type transform` ; if (`size ($LIST)` > 0) { for ($ELEMENT in `ls -sl -type transform`) eval ("xform -p 1 -roo \"" + $ORDER + "\" " + $ELEMENT) ; print (" // Result : Changed " + `size ($LIST)` + " rotation orders. //\n") ; llROColorButtons ; } else error ("Select at least one transform node.") ; } ; // global proc llMakeRotateOrder ////////////////////////////////// // llRotateOrder // ////////////////////////////////// // // MAIN PROC // // Builds the window and calls on to // llMakeRotateOrder when any button is pressed. // // --> llMakeRotateOrder // --> llROColorButtons // ///////////////////////////////// global proc llRotateOrder () { if (`window -ex llRotateOrderWindow`) deleteUI llRotateOrderWindow ; window -wh 132 72 -s 0 -minimizeButton 0 -maximizeButton 0 -title "llRotateOrder" llRotateOrderWindow ; rowColumnLayout -nc 3 -rat 1 "top" 2 -rat 2 "top" 2 -rat 3 "top" 2 -cs 1 2 -cs 2 2 -cw 1 40 -cw 2 40 -cw 3 40 ; button -l "xyz" -c "llMakeRotateOrder (\"xyz\")" llROWB0 ; button -l "yzx" -c "llMakeRotateOrder (\"yzx\")" llROWB1 ; button -l "zxy" -c "llMakeRotateOrder (\"zxy\")" llROWB2 ; button -l "xzy" -c "llMakeRotateOrder (\"xzy\")" llROWB3 ; button -l "yxz" -c "llMakeRotateOrder (\"yxz\")" llROWB4 ; button -l "zyx" -c "llMakeRotateOrder (\"zyx\")" llROWB5 ; showWindow llRotateOrderWindow ; window -e -wh 132 72 llRotateOrderWindow ; llROColorButtons ; scriptJob -p llRotateOrderWindow -event SelectionChanged llROColorButtons ; } ; // global proc llRotateOrder //////////////////////////////////////////////////////////////////////////////////////////////////// // // EoS llRotateOrder // ////////////////////////////////////////////////////////////////////////////////////////////////////