// Creation Date: Jan-05-2002 // Last Updated: Jan-05-2002 // Revision: 1.0 // Tested on Maya: 4.01 (should work in previous Maya versions) // // Author: Gino Dammers - gdammers@xs4all.nl // // Procedure Name: // // nodeLister // // Description: // // Lists all nodes of a specific type in your scene. // This comes in handy when for example, you're looking for all // the layeredTexture nodes to rename them from layeredTexture## to "LT_name" // nodeLister also comes in handy when searching for duplicate names like joint1|joint1|joint1 // // Note: // isValidName and renameNode: grabbed from SoundPanel.mel // Copyright (C) 1997-1998 Alias|Wavefront // Original Author: Paul Anand // // proc int isValidName( string $name ) { int $isValid = true; string $regex = "[^0-9a-zA-Z_]"; string $match = match( $regex, $name ); if ($match != "") { $isValid = false; confirmDialog -title "Alert" -button "OK" -defaultButton "OK" -message " Name contains illegal characters. Please select another. " -parent nodeLister; } else { $regex = "[a-zA-Z_][0-9a-zA-Z_]*"; $match = match( $regex, $name ); if ($match != $name) { $isValid = false; confirmDialog -title "Alert" -button "OK" -defaultButton "OK" -message " Name is not valid. Please select another. " -parent nodeLister; } } return $isValid; } global proc renameNode( string $currentNode ) { if ($currentNode != "Universe") { string $result = `promptDialog -title "Rename Node" -message "Enter New Node Name:" -text $currentNode -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel" -parent nodeLister`; if ( $result == "OK" ) { string $newNodeName = `promptDialog -q`; if ( isValidName($newNodeName) ) { if (catch($newNodeName = `rename $currentNode $newNodeName`)) { confirmDialog -title "Alert" -button "OK" -defaultButton "OK" -message " Error in trying to rename Node. Please select another " -parent nodeLister; } } } } else { warning( "Node cannot be renamed" ); } } global proc string[] listNodes () { string $Nodes[]; string $nodeType = `optionMenu -q -v nodeTypeListerOptionMenu`; if ($nodeType == "ls_materials") { $Nodes = `ls -mat`; } else if ($nodeType == "ls_textures") { $Nodes = `ls -tex`; } else if ($nodeType == "ls_lights") { $Nodes = `ls -lights`; } else if ($nodeType == "ls_cameras") { $Nodes = `ls -cameras`; } else if ($nodeType == "ls_shapes") { $Nodes = `ls -shapes`; } else if ($nodeType == "ls_transforms") { $Nodes = `ls -transforms`; } else { $Nodes = `ls -type $nodeType`; } return $Nodes; } global proc updateNodeListerButtons( ) { if( 0 == `textScrollList -q -nsi nodeList` ) { button -e -enable false renameButton; button -e -enable false deleteButton; button -e -enable false selectButton; } else if( 1 == `textScrollList -q -nsi nodeList` ) { button -e -enable true renameButton; button -e -enable true deleteButton; button -e -enable true selectButton; } else { button -e -enable false renameButton; button -e -enable true deleteButton; button -e -enable true selectButton; } } global proc updatenodeLister( ) { textScrollList -e -ra nodeList; string $Nodes[] = `listNodes`; for( $item in $Nodes ) { textScrollList -e -a $item nodeList; } } global proc nodeListerHelp() { print " /////////////////////////////////////////////////////////////////////////////// \n"; print " // Creation Date: Jan-05-2002 \n"; print " // Last Updated: Jan-05-2002 \n"; print " // Revision: 1.0 \n"; print " // Tested on Maya: 4.01 (should work in previous Maya versions) \n"; print " // \n"; print " // nodeLister 1.0 \n"; print " // Lists all nodes of a specific type in your scene.\n"; print " // This comes in handy when for example, you're looking for all\n"; print " // the layeredTexture nodes to rename them from layeredTexture## to \"LT_name\" \n"; print " // nodeLister also comes in handy when searching for duplicate names like joint1|joint1|joint1 \n"; print " /////////////////////////////////////////////////////////////////////////////// \n"; print " // See script editor for detail \n"; } global proc nodeCmd( string $cmd ) { switch( $cmd ) { case "rename": string $selNodes[] = `textScrollList -q -si nodeList`; renameNode $selNodes[0]; updatenodeLister; break; case "delete": string $selNodes[] = `textScrollList -q -si nodeList`; for( $node in $selNodes ) { delete $node; } updatenodeLister; break; case "select": string $selNodes[] = `textScrollList -q -si nodeList`; select $selNodes; break; } } global proc nodeLister() { string $nodeTypes[] = `ls -nt`; if( `window -exists nodeLister` ) { // deleteUI -window nodeLister; updatenodeLister; showWindow nodeLister; return; } window -t "Node Lister" -wh 340 680 -iconName "USERMENUICONWINDOW.BMP" -menuBar true -menuBarVisible true -s true nodeLister; menu -label "Help" -tearOff 0; menuItem -label "Script Information" -c "nodeListerHelp"; menuItem -divider 1; menuItem -label "Visit Homepage" -c "showHelp -a \"http://www.noAddressYet.com/index.html\""; formLayout nodeListerForm; optionMenu -l "Node Type" -cc updatenodeLister nodeTypeListerOptionMenu; menuItem -label "file"; menuItem -label "layeredShader"; menuItem -label "layeredTexture"; menuItem -label "shadingEngine"; menuItem -label "imagePlane"; menuItem -label "joint"; menuItem -label "locator"; menuItem -label "=======^^ Favorites ^^=======" -en false; menuItem -label "-" -en false; menuItem -label "====== (ls) filtered Nodes =====" -en false; menuItem -label "ls_materials"; menuItem -label "ls_textures"; menuItem -label "ls_lights"; menuItem -label "ls_cameras"; menuItem -label "ls_shapes"; menuItem -label "ls_transforms"; menuItem -label "======== All nodes ==========" -en false; for ($i = 0; $i < size($nodeTypes); $i++) { menuItem -label $nodeTypes[$i]; } textScrollList -ams true -dkc "nodeCmd delete" -dcc "nodeCmd select" -sc "nodeCmd select;updateNodeListerButtons" nodeList; separator -style "in" Nodesep; columnLayout nodeBtnLayout; button -h 26 -w 80 -l "Rename" -c "nodeCmd rename" -enable false renameButton; button -h 26 -w 80 -l "Delete" -c "nodeCmd delete" -enable false deleteButton; separator -style "in" -w 80 -h 10; button -h 26 -w 80 -l "Select" -c "nodeCmd select" -enable false selectButton; separator -style "in" -w 80 -h 10; setParent ..; button -h 26 -w 80 -l "Update" -c "updatenodeLister" updateButton; button -h 26 -w 80 -l "Close" -c "deleteUI nodeLister" closeButton; setParent ..; formLayout -e -af nodeList top 30 -ac nodeList right 5 nodeBtnLayout -af nodeList left 5 -ac nodeList bottom 5 Nodesep -af nodeBtnLayout top 5 -af nodeBtnLayout right 5 -an nodeBtnLayout left -ac nodeBtnLayout bottom 5 Nodesep -af Nodesep left 0 -af Nodesep right 0 -ac Nodesep bottom 5 updateButton -an Nodesep top -af updateButton left 5 -af updateButton bottom 5 -ap updateButton right 3 50 -an updateButton top -ap closeButton left 2 50 -af closeButton bottom 5 -af closeButton right 5 -an closeButton top nodeListerForm; scriptJob -p "nodeLister" -e "NewSceneOpened" "updatenodeLister"; scriptJob -p "nodeLister" -e "SceneOpened" "updatenodeLister"; updatenodeLister; showWindow nodeLister; }