// llListUtilities // ////////////////////////// // // Maya script file // ////////////////////////// // // Author : Lluís Llobera // (lluisllobera@rigging101.com) // // Creation date : 14/IV/2003 // Update 1.1 : 26/IV/2003 // Update 1.2 : 30/IV/2004 // Update 1.5 : 6/VII/2004 // Update 1.55 : 21/VII/2004 // Update 1.75 : 25/VII/2004 // // Main procedure : type "llListUtilities" in the Command Line or Script Editor // ////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // This script will create a window listing the most significant Maya utility nodes, such as // the condition, the multiplyDivide and the setRange. // // Most Maya users won't be familiar with them, but I use them a lot; and since it always takes me a long way // to find them once created... Hence this script! // // UPDATE 1.1 // Included "blendColors" utility, as well as ordered the elements in the "filters" column alphabetically. // // UPDATE 1.2 // Included "blendWeighted" utility. // // UPDATE 1.5 // Included a bunch of new utilities. // Also re-worked the callback for the filters creation, plus added a "create" button for each utility. // Thanks to for Alessandro Sabatelli the feedback !! :-) // // UPDATE 1.55 // Added Connection Editor button and better visual for utility labels. // Thanks to Javier Solsona for the cool idea !! :-) // // UPDATE 1.75 // New popup menu in the textScrollList with very useful features : Attribute Editor, Load in the Left or Right // side of the Connection Editor, show DG in Hypergraph or Hypershade , and print Inputs or Outputs. // Again, thanks to Javier Solsona for the input. // // // Enjoy!! // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// // global string $NODETYPES[] // ////////////////////////////////// // // This string[] contains a list of all the node types // handled by the script. // ///////////////////////////////// global string $NODETYPES [] = { "blendColors" , "choice" , "chooser" , "clamp" , "condition" , "curveInfo" , "multiplyDivide" , "plusMinusAverage" , "reverse" , "setRange" , "timeToUnitConversion" , "unitConversion" , "unitToTimeConversion" , "vectorProduct" } ; //////////////////////////////////////// // global proc llLUPrintConnections // //////////////////////////////////////// // // Prints the inputs ($TYPE = 0) or outputs ($TYPE = 1) // of the utilities selected in the textScrollList. // // <-- llListUtilities // /////////////////////////////////////// global proc llLUPrintConnections (int $TYPE) { string $SELECTED[] = `textScrollList -q -si llListUtilitiesScroll` ; string $SPECIFY[] = {"inputs" , "outputs"} ; string $CONNECTIONS[] ; // all the connections string $SPECIFIEDCONNECTIONS[] ; // only inputs or only outputs int $J ; print "\n" ; if (`size $SELECTED` > 0) for ($ELEMENT in $SELECTED) { string $NODETYPE = `match "-----" $ELEMENT` ; if ($NODETYPE != "-----") { $CONNECTIONS = eval ("listConnections -p 1 -c 1 " + $ELEMENT) ; $SPECIFIEDCONNECTIONS = eval ("listConnections -p 1 -s " + (!$TYPE) + " -d " + ($TYPE) + " " + $ELEMENT) ; print ("\n ----- " + $SPECIFY[$TYPE] + " of " + $ELEMENT + " -----\n") ; if (`size $SPECIFIEDCONNECTIONS` > 0) for ($I = 0 ; $I <= (`size $SPECIFIEDCONNECTIONS` -1) ; $I++) { $J = 0 ; while ($CONNECTIONS[$J] != $SPECIFIEDCONNECTIONS[$I]) $J++ ; if ($TYPE == 0) // inputs specified print ($CONNECTIONS[$J] + " -> " + $CONNECTIONS[($J-1)] + "\n") ; else // outputs specified print ($CONNECTIONS[($J-1)] + " -> " + $CONNECTIONS[$J] + "\n") ; } ; // for $I in $CONNECTIONS } ; // if ($NODETYPE != "-----") } ; // for ($ELEMENT in $SELECTED) } ; // global proc llLUPrintConnections ///////////////////////////////////////// // global proc llLUGraphInHypershade // ///////////////////////////////////////// // // Graphs in the Hypershade the DG for the utilities // selected in the textScrollList. // // <-- llListUtilities // --> llListUtilitiesSelectItem // //////////////////////////////////////// global proc llLUGraphInHypershade () { string $CURRENTSELECTION[] = `ls -sl` ; llListUtilitiesSelectItem ; if (!`window -ex hyperShadePanel1Window`) HypershadeWindow ; hyperShadePanelGraphCommand("hyperShadePanel1", "showUpAndDownstream") ; select -r $CURRENTSELECTION ; } ; // global proc llLUGraphInHypershade ///////////////////////////////////////// // global proc llLUGraphInHypergraph // ///////////////////////////////////////// // // Graphs in the HyperGraph the DG for the utilities // selected in the textScrollList. // // <-- llListUtilities // --> llListUtilitiesSelectItem // //////////////////////////////////////// global proc llLUGraphInHypergraph () { string $CURRENTSELECTION[] = `ls -sl` ; llListUtilitiesSelectItem ; if (!`window -ex hyperGraphPanel1Window`) HypergraphWindow ; showDGLevel hyperGraphPanel1HyperGraphEd ; select -r $CURRENTSELECTION ; } ; // global proc llLUGraphInHypergraph ////////////////////////////////// // global proc llLUShowInCE // ////////////////////////////////// // // Loads the utilities selected in the textScrollList in the // left or right side of the Connection Editor. // // <-- llListUtilities // --> llListUtilitiesSelectItem // ///////////////////////////////// global proc llLUShowInCE (int $SIDE) { string $CURRENTSELECTION[] = `ls -sl` ; string $SELECTED[] = `textScrollList -q -si llListUtilitiesScroll` ; llListUtilitiesSelectItem ; if (!`window -ex connectWindow`) ConnectionEditor ; connectWindowFillFromActiveList $SIDE ; select -r $CURRENTSELECTION ; } ; // global proc llLUCShowInCE ////////////////////////////////// // global proc llLUShowInAE // ////////////////////////////////// // // Shows the first of the selected utilities // in the Attribute Editor. // // <-- llListUtilities // ///////////////////////////////// global proc llLUShowInAE () { string $SELECTED[] = `textScrollList -q -si llListUtilitiesScroll` ; string $SELECTEDNODES[] ; int $SIZE ; for ($ELEMENT in $SELECTED) { string $NODETYPE = `match "-----" $ELEMENT` ; if ($NODETYPE != "-----") { $SELECTEDNODES[$SIZE] = $ELEMENT ; $SIZE ++ ; } ; // if } ; // for if (`size $SELECTEDNODES` > 0) eval ("showEditor " + $SELECTEDNODES[0]) ; } ; // global proc llLUCShowInAE /////////////////////////////////////////////// // global proc llListUtilitiesSetPopupMenu // /////////////////////////////////////////////// // // Enables or disables the menuItems for the popup menu in the // textScrollList, depending on if there are selected utilities. // // <-- llListUtilities // /////////////////////////////////////////////// global proc llListUtilitiesSetPopupMenu () { string $SELECTED[] = `textScrollList -q -si llListUtilitiesScroll` ; string $NAME = "no utility nodes selected" ; int $ENABLE = 0 ; if (`size $SELECTED` > 0) for ($ELEMENT in $SELECTED) { string $NODETYPE = `match "-----" $ELEMENT` ; if ($NODETYPE != "-----") if ($ENABLE == 0) { $ENABLE = 1 ; $NAME = $ELEMENT ; } // if ($ENABLE == 0) else if (!`gmatch $NAME "* .."`) $NAME += " .." ; } ; // for ($ELEMENT in $SELECTED) menuItem -e -en $ENABLE -l $NAME llLUCPMName ; menuItem -e -en $ENABLE llLUCPMAttributeEditor ; menuItem -e -en $ENABLE llLUCPMLeftSide ; menuItem -e -en $ENABLE llLUCPMRightSide ; menuItem -e -en $ENABLE llLUCPMHypergraph ; menuItem -e -en $ENABLE llLUCPMHypershade ; menuItem -e -en $ENABLE llLUCPMPrintInputs ; menuItem -e -en $ENABLE llLUCPMPrintOutputs ; } ; // global proc llListUtilitiesSetPopupMenu ////////////////////////////////// // llLUCreateNode // ////////////////////////////////// // // When the "C" button next to an utility name is // pressed, this new utility node is created. // If the checkbox for this utility is ON, // the llListUtilities window is also refreshed. // // <-- llListUtilities // ///////////////////////////////// global proc llLUCreateNode (string $TYPE , string $NAME) { if ($NAME != "") createNode ($TYPE) -n ($NAME) ; else createNode ($TYPE) ; if (`checkBox -q -v ("llListUtilitiesItem" + $TYPE)`) llListUtilitiesRefresh ; } ; // global proc llLUCreateNode ////////////////////////////////// // llLUName // ////////////////////////////////// // // Creates a dialog box prompting the user to // enter a name for the new requested node type // // <-- llListUtilities // ///////////////////////////////// global proc llLUName (string $TYPE) { string $result = `promptDialog -title ($TYPE + " name :") -message "Enter name :" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`; if ($result == "OK") { string $NAME = `promptDialog -q -text` ; llLUCreateNode ($TYPE , $NAME) ; } ; // if (OK) } ; // global proc llLUName ////////////////////////////////// // llListUtilitiesSelectAll // ////////////////////////////////// // // When the "select all" or "un-select all" buttons are pressed, // this proc will change the value of the check boxes accordingly // and, after that, refresh the scroll list // // <-- llListUtilities // ///////////////////////////////// global proc llListUtilitesSelectAll (int $SELECT) { global string $NODETYPES[] ; // toggle the status of the check boxes for ($NODE in $NODETYPES) checkBox-e -v $SELECT ("llListUtilitiesItem" + $NODE) ; // refresh window llListUtilitiesRefresh ; } ; // global proc llListUtilitiesSelectAll ////////////////////////////////// // llListUtilitiesSelectItem // ////////////////////////////////// // // Whenever any items from the scroll list are selected, this proc // will run through them to check if the "title" items of each category // are in the selection. If so, they will not be considered. The final // result of the proc is that the selected items in the scroll list will // be selected in Maya. // // <-- llListUtilities // <-- llListUtilitiesShowInHypergraph // <-- llListUtilitiesShowInHypershade // <-- llListUtilitiesShowInCE // ///////////////////////////////// global proc llListUtilitiesSelectItem () { select -cl ; // get the names of the selected items string $SELECTED[] = `textScrollList -q -si llListUtilitiesScroll` ; // if any of the names is a "utility node", erase it from the list for ($ELEMENT in $SELECTED) { string $NODETYPE = `match "-----" $ELEMENT` ; if ($NODETYPE != "-----") select -tgl $ELEMENT ; } ; // for } ; // global proc llListUtilitiesSelectItem //////////////////////////////////// // llListUtilitiesChangeFilters // //////////////////////////////////// // // Whenever the "FILTER" button is pressed, this script will be called on. // It just checks if the button is wanted to expand or contract // the section of the window, and goes on to call the adequate proc. // // <-- llListUtilities // --> llListUtilitiesShowFilters // --> llListUtilitiesHideFilters // ///////////////////////////////// global proc llListUtilitesChangeFilters () { // get the label in the button // to know if filters should be ON or OFF string $TEXTBUTTON = `button -q -l llListUtilitiesFiltersButton` ; if ($TEXTBUTTON == "FILTER >>") llListUtilitiesShowFilters ; else llListUtilitiesHideFilters ; } ; // global proc llListUtilitesChangeFilters ////////////////////////////////// // llListUtilitiesShowFilters // ////////////////////////////////// // // The "filters" section is shown. // The "filters" layout is made visible, the window // changes size, the label of the button is updated, // and so is the formLayout's configuration. // // <-- llListUtilitiesChangeFilters // ///////////////////////////////// global proc llListUtilitiesShowFilters () { // change the visibility of the filters layout scrollLayout -e -vis 1 llListUtilitiesFilters ; // change the size of the window int $SIZEW = `window -q -w llListUtilitiesWindow` + 230 ; window -e -w $SIZEW llListUtilitiesWindow ; // change the label of the button button -e -l "FILTER <<" llListUtilitiesFiltersButton ; // change the configuration of the formLayout formLayout -e -attachForm llListUtilitiesOptionsLayout "bottom" 2 -attachForm llListUtilitiesOptionsLayout "left" 2 -attachControl llListUtilitiesOptionsLayout "right" 2 llListUtilitiesFilters -attachNone llListUtilitiesOptionsLayout "top" -attachForm llListUtilitiesScroll "top" 2 -attachForm llListUtilitiesScroll "left" 2 -attachControl llListUtilitiesScroll "bottom" 2 llListUtilitiesOptionsLayout -attachControl llListUtilitiesScroll "right" 2 llListUtilitiesFilters -attachForm llListUtilitiesFilters "top" 2 -attachForm llListUtilitiesFilters "right" 2 -attachNone llListUtilitiesFilters "left" -attachForm llListUtilitiesFilters "bottom" 2 llListUtilitiesWindowForm ; } ; // global proc llListUtilitiesShowFilters ////////////////////////////////// // llListUtilitiesHideFilters // ////////////////////////////////// // // The "filters" section is hidden. // The "filters" layout is made invisible, the window // changes size, the label of the button is updated, // and so is the formLayout's configuration. // // <-- llListUtilitiesChangeFilters // ///////////////////////////////// global proc llListUtilitiesHideFilters () { // change the visibility of the filters layout scrollLayout -e -vis 0 llListUtilitiesFilters ; // change the size of the window int $SIZEW = `window -q -w llListUtilitiesWindow` - 230 ; window -e -w $SIZEW llListUtilitiesWindow ; // change the label of the button button -e -l "FILTER >>" llListUtilitiesFiltersButton ; formLayout -e -attachForm llListUtilitiesOptionsLayout "bottom" 2 -attachForm llListUtilitiesOptionsLayout "left" 2 -attachForm llListUtilitiesOptionsLayout "right" 2 -attachNone llListUtilitiesOptionsLayout "top" -attachForm llListUtilitiesScroll "top" 2 -attachForm llListUtilitiesScroll "left" 2 -attachControl llListUtilitiesScroll "bottom" 2 llListUtilitiesOptionsLayout -attachForm llListUtilitiesScroll "right" 2 llListUtilitiesWindowForm ; } ; // global proc llListUtilitiesShowFilters ////////////////////////////////// // llListUtilitiesRefreshItem // ////////////////////////////////// // // The scroll list is updated for each category. // The proc takes into account the state of the // category's checkBox to decide whether it should be // taken into consideration. // If so, and if the category is not empty, a "category title" // is written in the scroll list. // // <-- llListUtilitiesRefresh // ///////////////////////////////// global proc llListUtilitiesRefreshItem (string $TYPE) { // get variables int $ENABLED = `checkBox -q -v ("llListUtilitiesItem" + $TYPE)` ; string $LIST[] = `ls -type $TYPE` ; // append items to the scroll list if ((`size $LIST` > 0) && ($ENABLED == 1)) { textScrollList -e -append (" ----- "+$TYPE+" ----- ") llListUtilitiesScroll ; for ($ELEMENT in $LIST) textScrollList -e -fn "plainLabelFont" -append $ELEMENT llListUtilitiesScroll ; } ; // if } ; // global proc llListUtilitiesRefreshItem ////////////////////////////////// // llListUtilitiesRefresh // ////////////////////////////////// // // The scroll list is cleared. // For each utility, the proc llListUtilitiesRefreshItem is called on. // // <-- llListUtilities // --> llListUtilitiesRefreshItem // ///////////////////////////////// global proc llListUtilitiesRefresh () { global string $NODETYPES[] ; // clear list textScrollList -e -ra llListUtilitiesScroll ; // for each of the types of nodes, get if they are // selected and, if so, list them for ($NODE in $NODETYPES) llListUtilitiesRefreshItem ($NODE) ; } ; // global proc llListUtilitiesRefresh ////////////////////////////////// // llListUtilities // ////////////////////////////////// // // MAIN PROC // // The main window is drawn. // // --> llListUtilitiesSelectAll // --> llListUtilitiesSelectItem // --> llListUtilitiesChangeFilters // --> llListUtilitiesRefresh // ///////////////////////////////// global proc llListUtilities () { global string $NODETYPES[] ; // creates the window if (`window -ex llListUtilitiesWindow`) deleteUI llListUtilitiesWindow ; window -t "llListUtilitiesWindow v1.75" llListUtilitiesWindow ; // form Layout definition formLayout llListUtilitiesWindowForm ; // llListUtilitiesScroll scroll list definition textScrollList -ams 1 -selectCommand llListUtilitiesSelectItem -dcc "llLUShowInAE" llListUtilitiesScroll ; popupMenu -pmc "llListUtilitiesSetPopupMenu" ; menuItem -l "" -c llListUtilitiesSelectItem llLUCPMName ; menuItem -d 1 llLUCPMSeparator1 ; menuItem -d 1 llLUCPMSeparator2 ; menuItem -l "Attribute Editor" -c "llLUShowInAE" llLUCPMAttributeEditor ; menuItem -d 1 llLUCPMSeparator3 ; menuItem -l "Left Side of Connection Editor" -c "llLUShowInCE (0)" llLUCPMLeftSide ; menuItem -l "Right Side of Connection Editor" -c "llLUShowInCE (1)" llLUCPMRightSide ; menuItem -d 1 llLUCPMSeparator4 ; menuItem -l "Show DG in Hypergraph" -c "llLUGraphInHypergraph" llLUCPMHypergraph ; menuItem -l "Show DG in Hypershade" -c "llLUGraphInHypershade" llLUCPMHypershade ; menuItem -d 1 llLUCPMSeparator5 ; menuItem -l "Print Input Connections" -c "llLUPrintConnections (0)" llLUCPMPrintInputs ; menuItem -l "Print Output Connections" -c "llLUPrintConnections (1)" llLUCPMPrintOutputs ; setParent llListUtilitiesWindowForm ; // llListUtilitiesOptionsLayout layout definition formLayout llListUtilitiesOptionsLayout ; button -l "Refresh" -c "llListUtilitiesRefresh" llListUtilitiesRefreshButton ; button -l "FILTER >>" -c "llListUtilitesChangeFilters" llListUtilitiesFiltersButton ; formLayout -e -attachForm llListUtilitiesRefreshButton "top" 0 -attachForm llListUtilitiesRefreshButton "left" 0 -attachForm llListUtilitiesRefreshButton "bottom" 0 -attachControl llListUtilitiesRefreshButton "right" 0 llListUtilitiesFiltersButton -attachForm llListUtilitiesFiltersButton "top" 0 -attachPosition llListUtilitiesFiltersButton "left" 0 60 -attachForm llListUtilitiesFiltersButton "bottom" 0 -attachForm llListUtilitiesFiltersButton "right" 0 llListUtilitiesOptionsLayout ; setParent llListUtilitiesWindowForm ; // llListUtilitiesFilter defintion scrollLayout -cr 0 -mcw 230 -w 245 llListUtilitiesFilters ; columnLayout -w 210 -rs 2 -cat "both" 30 -adj 1 llListUtilitiesFiltersLayout ; separator -style "none" -h 2 ; separator -style "none" -h 5 ; rowColumnLayout -nc 2 -cw 1 150 -cw 2 20 ; for ($NODE in $NODETYPES) { checkBox -al "left" -v 1 -l $NODE -onc llListUtilitiesRefresh -ofc llListUtilitiesRefresh ("llListUtilitiesItem" + $NODE) ; button -w 10 -l "C" -c ("llLUCreateNode (\"" + $NODE + "\" , \"\")") ; popupMenu ; menuItem -l "create .." -c ("llLUName (\"" + $NODE + "\")") ; } ; // for ($NODE in $NODETYPES) setParent .. ; separator -style "none" -h 5 ; button -l "check all" -c "llListUtilitesSelectAll (1)" ; button -l "un-check all" -c "llListUtilitesSelectAll (0)" ; separator -h 5 -style "none" ; button -l "Connection Editor" -c "ConnectionEditor" ; setParent llListUtilitiesWindowForm ; // form Layout configuration window -e -w 300 llListUtilitiesWindow ; llListUtilitiesHideFilters ; // refresh scroll list llListUtilitiesRefresh ; // script jobs scriptJob -p llListUtilitiesWindow -event deleteAll llListUtilitiesRefresh ; // showWindow showWindow llListUtilitiesWindow ; // edit window size window -e -wh 250 500 llListUtilitiesWindow ; } ; // global proc llListUtilies ; ///////////////////////////////////////////////////////////////////////////////////////////////////////////// // // EoS llListUtilities // /////////////////////////////////////////////////////////////////////////////////////////////////////////////