// llMonitorAttribute // ////////////////////////// // // Maya script file // ////////////////////////// // // Author : Lluís Llobera // (lluisllobera@hotmail.com) // // Creation date : 19/X/2003 // // Main procedure : type "llMonitorAttribute" in the Command Line or Script Editor // ////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // // With this script, the user can quickly set up a window with a list of attributes from // different objects, and see how they change in real-time. // // // Enjoy!! // //////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// // llMASeparateAtt // ////////////////////////////////// // // This proc returns the attribute name, given a string with the format "obj.att" // // <-- llMAAddAttribute // ///////////////////////////////// global proc string llMASeparateAtt (string $INPUT) { int $INPUTSIZE = `size $INPUT` ; int $SEPARATORPLACE ; int $SEPARATOR = 0 ; for ($I = 1 ; $I < $INPUTSIZE ; $I++) { string $CHAR = `substring $INPUT $I $I` ; if ($CHAR == ".") $SEPARATORPLACE = $I ; } ; // for return `substring $INPUT ($SEPARATORPLACE+1) $INPUTSIZE` ; } ; // global proc string llMASeparateAtt ////////////////////////////////// // llMASeparateName // ////////////////////////////////// // // This proc returns the object name, given a string with the format "obj.att"// // // <-- llMAAddAttribute // /////////////////////////////////// global proc string llMASeparateName (string $INPUT) { int $INPUTSIZE = `size $INPUT` ; int $SEPARATOR = 0 ; int $SEPARATORPLACE ; for ($I = 1 ; $I < $INPUTSIZE ; $I++) { string $CHAR = `substring $INPUT $I $I` ; if ($CHAR == ".") $SEPARATORPLACE = $I ; } ; // for return `substring $INPUT 1 ($SEPARATORPLACE-1)` ; } ; // global proc string llMASeparateName ////////////////////////////////// // llMAParseAddAttr // ////////////////////////////////// // // This proc gets the string from the main window, // evaluates it, then goes on to call llMAAddAttr // // <-- llMonitorAttribute // --> llMASeparateAtt // --> llMASeparateName // /////////////////////////////////// global proc llMAParseAddAttr () { // variables declaration string $INPUT = `textField -q -tx llMAAttributeInputText` ; string $OBJ ; string $ATT ; int $ERROR = 0 ; // proc start if (!`objExists $INPUT`) error ("Specified object / attribute do not exist.") ; else { $OBJ = llMASeparateName ($INPUT) ; $ATT = llMASeparateAtt ($INPUT) ; llMAAddAttr ($OBJ , $ATT) ; } ; // else textField -e -tx "" llMAAttributeInputText ; } ; // global proc llMAParseAddAttr ////////////////////////////////// // llMADeleteControl // ////////////////////////////////// // // After deleting a control, the window is resized depending on the number of elements it contains. // // <-- llMonitorAttribute // /////////////////////////////////// global proc llMADeleteControl () { // variables definition int $WINDOWSIZE = `window -q -h llMonitorAttributeWindow` ; floatField -e -v (`floatField -q -v llMANumberOfControls` -1) llMANumberOfControls ; // proc start if (`floatField -q -v llMANumberOfControls` == 0) // reset state { text -e -vis 1 llMATextElements ; window -e -wh 330 80 llMonitorAttributeWindow ; } else window -e -h (65 + (22 * `floatField -q -v llMANumberOfControls`)) llMonitorAttributeWindow ; } ; // global proc llMADeleteControl ////////////////////////////////// // llMAAddAttr // ////////////////////////////////// // // Creates a new control in the window layout // // <-- llMonitorAttribute // /////////////////////////////////// global proc llMAAddAttr (string $OBJ , string $ATTNAME) { // variables declaration string $ATTTYPE = eval ("getAttr -type " + $OBJ + "." + $ATTNAME ) ; // type of the attribute string $ATTCONTROL ; string $RCL ; int $WINDOWSIZE = `window -q -h llMonitorAttributeWindow` ; float $NUMBEROFCONTROLS = `floatField -q -v llMANumberOfControls` ; // proc start // filter : if unknown att type, get error -- else, go on if (($ATTTYPE == "double") || ($ATTTYPE == "doubleLinear") || ($ATTTYPE == "doubleAngle") || ($ATTTYPE == "double3") || ($ATTTYPE == "float3") || ($ATTTYPE == "bool") || ($ATTTYPE == "enum") || ($ATTTYPE == "string")) { // if there are no elements yet, delete the text if (`text -q -l llMATextElements` == "No elements in the layout") text -e -vis 0 llMATextElements ; $RCL = `rowColumnLayout -nc 2 -cw 1 280 -cw 2 30 -p llMAWLayout` ; switch ($ATTTYPE) { case "doubleLinear" : $ATTCONTROL = `floatFieldGrp -p $RCL -cw 1 125 -cw 2 50 -pre 4 -l ($OBJ + "." + $ATTNAME) -nf 1 ($RCL + "Control")` ; eval ("connectControl -in 2 " + $ATTCONTROL + " (\"" + $OBJ + "." + $ATTNAME + "\")") ; floatField -e -v ($NUMBEROFCONTROLS + 1) llMANumberOfControls ; break ; // doubleLinear case "double" : $ATTCONTROL = `floatFieldGrp -p $RCL -cw 1 125 -cw 2 50 -pre 4 -l ($OBJ + "." + $ATTNAME) -nf 1 ($RCL + "Control")` ; eval ("connectControl -in 2 " + $ATTCONTROL + " (\"" + $OBJ + "." + $ATTNAME + "\")") ; floatField -e -v ($NUMBEROFCONTROLS + 1) llMANumberOfControls ; break ; // double case "doubleAngle" : $ATTCONTROL = `floatFieldGrp -p $RCL -cw 1 125 -cw 2 50 -pre 4 -l ($OBJ + "." + $ATTNAME) -nf 1 ($RCL + "Control")` ; eval ("connectControl -in 2 " + $ATTCONTROL + " (\"" + $OBJ + "." + $ATTNAME + "\")") ; floatField -e -v ($NUMBEROFCONTROLS + 1) llMANumberOfControls ; break ; // doubleangle case "double3" : $ATTCONTROL = `floatFieldGrp -p $RCL -cw 1 125 -cw 2 50 -cw 3 50 -cw 4 50 -pre 4 -l ($OBJ + "." + $ATTNAME) -nf 3 ($RCL + "Control")` ; string $COMPOUNDATT[] = `listAttr ($OBJ + "." + $ATTNAME)` ; eval ("connectControl -in 2 " + $ATTCONTROL + " (\"" + $OBJ + "." + $COMPOUNDATT[1] + "\")") ; eval ("connectControl -in 3 " + $ATTCONTROL + " (\"" + $OBJ + "." + $COMPOUNDATT[2] + "\")") ; eval ("connectControl -in 4 " + $ATTCONTROL + " (\"" + $OBJ + "." + $COMPOUNDATT[3] + "\")") ; floatField -e -v ($NUMBEROFCONTROLS + 1) llMANumberOfControls ; break ; // double3 case "float3" : $ATTCONTROL = `floatFieldGrp -p $RCL -cw 1 125 -cw 2 50 -cw 3 50 -cw 4 50 -pre 4 -l ($OBJ + "." + $ATTNAME) -nf 3 ($RCL + "Control")` ; string $COMPOUNDATT[] = `listAttr ($OBJ + "." + $ATTNAME)` ; eval ("connectControl -in 2 " + $ATTCONTROL + " (\"" + $OBJ + "." + $COMPOUNDATT[1] + "\")") ; eval ("connectControl -in 3 " + $ATTCONTROL + " (\"" + $OBJ + "." + $COMPOUNDATT[2] + "\")") ; eval ("connectControl -in 4 " + $ATTCONTROL + " (\"" + $OBJ + "." + $COMPOUNDATT[3] + "\")") ; floatField -e -v ($NUMBEROFCONTROLS + 1) llMANumberOfControls ; break ; // float3 case "bool" : $ATTCONTROL = `intFieldGrp -p $RCL -l ($OBJ + "." + $ATTNAME) -cw 1 125 -cw 2 50 -nf 1 ($RCL + "Control")` ; eval ("connectControl -in 2 " + $ATTCONTROL + " (\"" + $OBJ + "." + $ATTNAME + "\")") ; floatField -e -v ($NUMBEROFCONTROLS + 1) llMANumberOfControls ; break ; // bool case "enum" : $ATTCONTROL = `intFieldGrp -p $RCL -l ($OBJ + "." + $ATTNAME) -cw 1 125 -cw 2 50 -nf 1 ($RCL + "Control")` ; eval ("connectControl -in 2 " + $ATTCONTROL + " (\"" + $OBJ + "." + $ATTNAME + "\")") ; floatField -e -v ($NUMBEROFCONTROLS + 1) llMANumberOfControls ; break ; // enum case "string" : $ATTCONTROL = `textFieldGrp -p $RCL -l ($OBJ + "." + $ATTNAME) -cw 1 125 -cw 2 150 ($RCL + "Control")` ; eval ("connectControl -in 2 " + $ATTCONTROL + " (\"" + $OBJ + "." + $ATTNAME + "\")") ; floatField -e -v ($NUMBEROFCONTROLS + 1) llMANumberOfControls ; break ; // string } ; // switch ($ATTTYPE) // add button to delete control button -w 30 -l "X" -c ("deleteUI " + $RCL + "; llMADeleteControl" ) ; // resize window window -e -h (65 + (22 * ($NUMBEROFCONTROLS+1))) llMonitorAttributeWindow ; } // if know att type else error ("not supported attribute type") ; } ; // global proc llMAAddAttr ////////////////////////////////// // llMonitorAttribute // ////////////////////////////////// // // MAIN PROC // // Creates the main window. // // --> llMAAddAttr // --> llMADeleteControl // --> llMAParseAttr // /////////////////////////////////// global proc llMonitorAttribute () { // variables definition // proc start if (`window -ex llMonitorAttributeWindow`) deleteUI llMonitorAttributeWindow ; window -t "llMonitorAttribute v1.0" -s 0 -wh 330 80 llMonitorAttributeWindow ; columnLayout -cat "both" 5 -rs 5 -adj 1 ; columnLayout -adj 1 llMAWLayout ; floatField -v 0 -vis 0 llMANumberOfControls ; text -fn "obliqueLabelFont" -l "No elements in the layout" llMATextElements ; setParent .. ; separator ; rowColumnLayout -nc 2 -cw 1 200 -cs 2 10 ; textField -tx "" -ec llMAParseAddAttr llMAAttributeInputText ; button -l "Add Attribute" -c llMAParseAddAttr ; window -e -wh 330 80 llMonitorAttributeWindow ; showWindow llMonitorAttributeWindow ; } ; // global proc llMonitorAttribute ///////////////////////////////////////////////////////////// // // EoS llMonitorAttribute // /////////////////////////////////////////////////////////////;