//wbScaleNode.mel (c) 2008 // Verision 1.1 // author: Walter Behrnes //Description: // This script automates scaling of selected nodes in a scene //Use: // source "...PathToScript.../wbScaleNode.mel"; snMakeWin(); // //Arguments: // //Returns: // //Dependancies: // // //Documentation: // //Examples: // //Notes: // // //Bugs: // // global proc snErrCheck() { //SET CHECK VAR int $objCount = 0; //CHECK FOR SELECTION int $areChannelsLocked = 0; //CHECK IF SCALE CHANNELS LOCKED string $whichChannels[]; //MAKE ARRAY TO HOLD LOCKED OBJS int $isTransform = 1; //CHECK TO SEE IF TRANSFORM OBJECT //GET CURRENT SELCTION string $userSel[] = `ls -sl`; if(size($userSel) == 0) { $objCount = 1; } //CHECK TO SEE IF ALL OBJECTS ARE TRANSFORM OBJECTS string $transforms[] = `ls -sl -type "transform"`; if(size($userSel) != size($transforms)) { $isTransform = 0; } //CHECK TO SEE IF OBJECTS HAVE LOCKED SCALE CHANNELS string $curSel; for($curSel in $userSel) { $isLockedX =`getAttr -l ($curSel+".sx")`; $isLockedY =`getAttr -l ($curSel+".sy")`; $isLockedZ =`getAttr -l ($curSel+".sz")`; if($isLockedX || $isLockedY || $isLockedZ ) { $areChannelsLocked = 1; string $theObj[1]; $theObj[0] = $curSel; appendStringArray($whichChannels, $theObj, 1); } } print "\n\n"; if($objCount == 1) { error ("ERROR 001: PLEASE MAKE A SELECTION"); } if($isTransform == 0) { error ("ERROR 002: PLEASE SELECT TRANSFORM OBJECTS ONLY"); } if($areChannelsLocked == 1) { string $theObj; for($theObj in $whichChannels) { print("LOCKED SCALE CHANNEL ON: "+$theObj+"\n"); } error ("ERROR 003: LOCKED CHANNELS. SEE LIST ABOVE"); } } global proc snRandomize() { //GET VALUES FROM WINDOW int $scaleType = `radioButtonGrp -q -sl snScaleType`; print $scaleType; float $maxScale = `floatSliderGrp -q -v snMax`; float $minScale = `floatSliderGrp -q -v snMin`; //GET SELECTION string $objects[] = `ls -sl -l`; string $object; for($object in $objects) { float $getRandom = rand($minScale,$maxScale); switch($scaleType) { case 1: //SCALE ABSOLUTE scale -a $getRandom $getRandom $getRandom $object; break; case 2: //SCALE RELATIVE scale -r $getRandom $getRandom $getRandom $object; break; case 3: float $getX = `getAttr ($object+".sx")`; float $getY = `getAttr ($object+".sy")`; float $getZ = `getAttr ($object+".sz")`; float $newX = $getX + $getRandom; float $newY = $getY + $getRandom; float $newZ = $getZ + $getRandom; scale -a $newX $newY $newZ $object; break; default: break; } } } global proc snMakeWin() { //DELETE OLD WINDOWS if(`window -exists wbAssetScale`) { deleteUI wbAssetScale; } //START WINDOW string $wbAssetScaleWindow = `window -widthHeight 410 600 -menuBar true -title "wbAssetScale" wbAssetScale`; ////////////////////////////////////////////////// // MENUS // ////////////////////////////////////////////////// //print "Making Window\n"; columnLayout -adjustableColumn true; floatSliderGrp -label "Minimum Scale" -field true -minValue 0 -maxValue 10 -fieldMinValue 0 -fieldMaxValue 500 -value .75 snMin; floatSliderGrp -label "Maximum Scale" -field true -minValue .1 -maxValue 10 -fieldMinValue .0001 -fieldMaxValue 1000 -value 1 snMax; radioButtonGrp -numberOfRadioButtons 3 -label "Scale Type" -labelArray3 "Absolute" "Relative" "Additive" -sl 2 snScaleType; button -label "Scale Assets!" -command "snDoTheWork();"; setParent ..; showWindow $wbAssetScaleWindow; window -e -w 450 -h 125 $wbAssetScaleWindow; } global proc snDoTheWork() { //CHECK FOR ERRORS snErrCheck(); //Randomize snRandomize(); }