// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // // // // // Creation Date: 17 December 1998 // Rewritten by: stefand // // Procedure Name: // prefixHierarchy // // Description: // Brings up a prompt dialog to ask the user for a prefix // to add to the names of a complete hierarchy, starting at the // selected nodes, and traversing the transform nodes downwards. // // Note: this does no checking for 'illegal' characters! This // should be added. // // Input Arguments: // None. // // Return Value: // None. // // rename a transform node by giving it a prefix // recurses to all children proc prefixNode(string $prefix, string $node) { // check if it is a transform or derived from transform. // We don't rename shapes since they will likely be renamed // when we renamed their parent transform. // string $isType[] = `ls -type transform $node`; if (size($isType) > 0 ) { // extract the name of this node from its full path // string $nodeName = `substitute ".*|" $node ""`; // rename this node // string $newName = `rename $node ( $prefix + $nodeName )`; } } global proc prefixHierarchy( ) { string $ok = (uiRes("m_prefixHierarchy.kOK")); string $cancel = (uiRes("m_prefixHierarchy.kCancel")); string $result = `promptDialog -title (uiRes("m_prefixHierarchy.kPrefixHierarchy")) -message (uiRes("m_prefixHierarchy.kEnterPrefix")) -text "prefix_" -button $ok -button $cancel -defaultButton $ok -cancelButton $cancel -dismissString $cancel `; // If the result was "OK", then proceed // if ( $result == $ok ) { // Get the prefix the user entered // string $prefix = `promptDialog -q`; // Get a list of all descendents (The nodes are ordered from // leaf to root // string $currentNodes[] = eval("listRelatives -pa -ad `ls -sl -l`"); // add the prefix to each descendent node // if ( size( $currentNodes ) > 0 ) { for( $i=0; $i < size( $currentNodes ); $i++ ) { prefixNode( $prefix, $currentNodes[$i] ); } } // get a list of nodes on the list $currentNodes = `ls -sl -l`; // add the prefix to each node on the active list // if ( size( $currentNodes ) > 0 ) { for( $i=0; $i < size( $currentNodes ); $i++ ) { prefixNode( $prefix, $currentNodes[$i] ); } } } }