{"id":80,"date":"2008-08-01T05:43:22","date_gmt":"2008-08-01T12:43:22","guid":{"rendered":"http:\/\/www.rodgreen.com\/wordpress\/?p=80"},"modified":"2008-08-01T05:43:22","modified_gmt":"2008-08-01T12:43:22","slug":"renaming-objects-in-maya-intermediate","status":"publish","type":"post","link":"https:\/\/www.rodgreen.com\/?p=80","title":{"rendered":"Renaming objects in Maya (intermediate)"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"98\" src=\"https:\/\/www.rodgreen.com\/wp-content\/uploads\/image\/Icons\/rename_intermediate.png\" width=\"306\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.rodgreen.com\/scripts\/mel\/renameIntermediate.mel\" onclick=\"window.open(this.href,'renameIntermediate','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,status'); return false\">[Download Script]<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>This is the second part to a three part tutorial on renaming objects in Maya.&nbsp; In the <a href=\"https:\/\/www.rodgreen.com\/wordpress\/?p=23\">first installment<\/a> we established a collection of procedures and a simple UI that allows multiple objects to be renamed.<\/p>\n<p>Some issues were identified with the methods used previously and so in this next stage I&#39;m going to evaluate the procedures and improve the script. Specifically this tutorial will address the following issues:<\/p>\n<ul>\n<li>The previous script is a handy quick renamer but doesn&rsquo;t always produce unique names for all objects<\/li>\n<li>Numerical increments with good padding options<\/li>\n<li>The UI was over simplified and could be improved with more options<\/li>\n<\/ul>\n<p><!--more--><\/p>\n<h3>What&#39;s the goal exactly?<\/h3>\n<p>We need to advance the existing tool to support the following:<\/p>\n<ul>\n<li>Sort the list of nodes using a more robust Hierarchy sort method<\/li>\n<li>Add&nbsp; support for incrementing names with padding ( i.e. &#39;001&#39; rather then just &#39;1&#39;)<\/li>\n<li>Improve UI<\/li>\n<\/ul>\n<h3>What could go wrong?<\/h3>\n<ul>\n<li>Since we are writing our own sorting method we need to make sure it&#39;s fast<\/li>\n<li>Manually incrementing object names could prove difficult with renaming hierarchy&#39;s of similar names<\/li>\n<\/ul>\n<h2>&nbsp;<\/h2>\n<h2>Lets get started&#8230;<\/h2>\n<hr \/>\n<h3>Utility procedures<\/h3>\n<pre> \n\n<\/pre>\n<h4 style=\"margin-left: 40px;\">getSelection (Unchanged)<\/h4>\n<pre style=\"margin-left: 80px;\">global proc string[] getSelection()\n{\n\treturn (ls(&quot;-selection&quot;, &quot;-long&quot;, &quot;-flatten&quot;));\n}\n<\/pre>\n<p style=\"margin-left: 40px;\">Description:<\/p>\n<p style=\"margin-left: 40px;\">While none of my core or utility procedures rely on switching and querying selection I do a lot of interfacing with the user through their selection. So a unified selection query procedure is important. The long and flatten flags returns the objects with long paths and flattened individualized list respectively.<\/p>\n<p style=\"margin-left: 40px;\">i.e.<\/p>\n<blockquote><p>&nbsp;<\/p><\/blockquote>\n<blockquote>\n<pre style=\"margin-left: 40px;\">{&quot;locator1&quot;, &quot;pCube1.uv[0:2]&quot;}<\/pre>\n<\/blockquote>\n<blockquote><p>&nbsp;<\/p><\/blockquote>\n<p style=\"margin-left: 40px;\">would return as<\/p>\n<blockquote><p>&nbsp;<\/p><\/blockquote>\n<blockquote>\n<pre style=\"margin-left: 40px;\">{&quot;|pCube1|pCube2|locator1&quot;, &quot;|pCube1.uv[0]&quot;, &quot;|pCube1.uv[1]&quot;, &quot;|pCube1.uv[2]&quot;}<\/pre>\n<\/blockquote>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<h4 style=\"margin-left: 40px;\">renameLong (Unchanged)<\/h4>\n<pre style=\"margin-left: 80px;\">global proc string renameLong(string $object, string $newName)\n{\n\treturn longNameOf(rename($object, $newName));\n}\n<\/pre>\n<p style=\"margin-left: 40px;\">Description:<\/p>\n<p style=\"margin-left: 40px;\">As the default rename procedure doesn&#39;t always return the long version of the object we&#39;ll create this wrapper procedure to ensure it does.<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<h4 style=\"margin-left: 40px;\">stringArrayFind (Unchanged)<\/h4>\n<pre style=\"margin-left: 80px;\">global proc int stringArrayFind(string $item, string $array[])\n{\n    for($i = 0; $i &lt; size($array); $i++) if($array[$i] == $item) return $i;\n    return -1;\n}\n<\/pre>\n<p style=\"margin-left: 40px;\">Description:<\/p>\n<p style=\"margin-left: 40px;\">Pretty routine procedure that returns the first index of a given &#39;item&#39; in a string array.<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<p style=\"margin-left: 40px;\">Details:<\/p>\n<p style=\"margin-left: 40px;\">This procedure will be called constantly throughout and therefore should be as efficient as possible.<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<h4 style=\"margin-left: 40px;\">getStringArrayMapping (Unchanged)<\/h4>\n<pre style=\"margin-left: 80px;\">global proc int[] getStringArrayMapping(string $unmodified[], string $modified[])\n{\n    int $returnArray[] = {};\n\n    string $searchList[] = $unmodified;\n\n    for($i = 0; $i &lt; size($modified); $i++)\n    {\n        int $foundIndex = stringArrayFind($modified[$i], $searchList);\n        $returnArray[$i] = $foundIndex;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $searchList[$foundIndex] = &quot;&quot;;\n&nbsp;&nbsp;&nbsp; }\n\n&nbsp;&nbsp;&nbsp; return $returnArray;\n}\n<\/pre>\n<p style=\"margin-left: 40px;\">Description:<\/p>\n<p style=\"margin-left: 40px;\">This procedure does a nice little trick of giving you the index mapping between $unmodified and $modified string arrays.&nbsp; What this basically means is it gives you how the order of strings has changed between the two given arrays.<\/p>\n<p style=\"margin-left: 40px;\">Why is this needed?<\/p>\n<p style=\"margin-left: 40px;\">If you reorder an array of objects there&#39;s no way to tell what order they were originally in and thus destroying the users specific selection order.&nbsp; So we create a list of indexes that provide a &#39;mapping&#39; between the original list and the modified list.<\/p>\n<p style=\"margin-left: 40px;\">i.e.<\/p>\n<p style=\"margin-left: 40px;\">If you sent this procedure a string array<\/p>\n<pre style=\"margin-left: 80px;\">$unmodified[] = {&quot;dog&quot;, &quot;mouse&quot;, &quot;cat&quot;}<\/pre>\n<p style=\"margin-left: 40px;\">and a string array<\/p>\n<pre style=\"margin-left: 80px;\">$modified[] = {&quot;mouse&quot;, &quot;cat&quot;, &quot;dog&quot;}<\/pre>\n<p style=\"margin-left: 40px;\">This procedure would return the index (int) array<\/p>\n<pre style=\"margin-left: 80px;\">$returnArray = {1, 2, 0}<\/pre>\n<p style=\"margin-left: 40px;\">as index &#39;1&#39; represented &quot;mouse&quot;, index &#39;2&#39; represented &quot;cat&quot; and index &#39;3&#39; represented &quot;dog&quot; in the $unmodified array.<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<p style=\"margin-left: 40px;\">Details:<\/p>\n<p style=\"margin-left: 40px;\">The following line is added for performance. Setting the found index to a zero length string or &quot;&quot; will speed up the string comparison inside the &#39;stringArrayFind&#39; procedure:<\/p>\n<pre style=\"margin-left: 80px;\">$searchList[$foundIndex] = &quot;&quot;;<\/pre>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<h4 style=\"margin-left: 40px;\">padInt<\/h4>\n<pre style=\"margin-left: 80px;\">global proc string padInt(int $inputInt, int $length)\n{\n    string $returnString = $inputInt;\n\n&nbsp;&nbsp; &nbsp;for($i = size($returnString); $i &lt; $length; $i++) $returnString = (&quot;0&quot; + $returnString);\n\n&nbsp;&nbsp; &nbsp;return $returnString;\n}\n<\/pre>\n<p style=\"margin-left: 40px;\">Description:<\/p>\n<p style=\"margin-left: 40px;\">This will take the input integer value and pad it with preceding zeros so that it fills a certain text length.<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<p style=\"margin-left: 40px;\">Details:<\/p>\n<p style=\"margin-left: 40px;\">If the $inputInt is longer in string length then the specific $length it will return the original int as a string.<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<h4 style=\"margin-left: 40px;\">countCharInString<\/h4>\n<pre style=\"margin-left: 80px;\">global proc int countCharInString(string $char, string $string)\n{\n\tint $count = 0;\n\tfor($i = 1; $i &lt;= size($string); $i++) if(substring($string, $i, $i) == $char) $count++;\n\treturn $count;\n}&nbsp;<\/pre>\n<p style=\"margin-left: 40px;\">Description:<\/p>\n<p style=\"margin-left: 40px;\">Counts the number of times $char appears in the given string ($string)<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<h4 style=\"margin-left: 40px;\">intArrayFloor<\/h4>\n<pre style=\"margin-left: 80px;\">global proc int intArrayFloor(int $intArray[])\n{\n    int $returnInt = $intArray[0];\n    for($eachInt in $intArray) if($eachInt &lt; $returnInt) $returnInt = $eachInt;\n\n    return $returnInt;\n}\n<\/pre>\n<p style=\"margin-left: 40px;\">Description:<\/p>\n<p style=\"margin-left: 40px;\">Returns the smallest value in the given int array ($intArray)<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<h4 style=\"margin-left: 40px;\">sortStringByInts<\/h4>\n<pre style=\"margin-left: 80px;\">global proc string[] sortStringByInts(string $stringArray[], int $intArray[])\n{\n\n\tstring $returnArray[] = {};\n\tint $arrayToSearch[] = $intArray;\n\tint $loopCount = size($arrayToSearch);\n\n\tint $floor = intArrayFloor($intArray);\n\t\n\tfor($retIndex = 0; $retIndex &lt; $loopCount; $retIndex++)\n\t{\n\t\tint $iMax = $floor;\n\t\tint $indexFound = -1;\n\t\tfor($i = 0; $i &lt; $loopCount; $i++)\n\t\t{\n\t\t\tint $eachInt = $arrayToSearch[$i];\t\n\t\t\tif( $eachInt &gt;= $iMax )\n\t\t\t{\n\t\t\t\t$iMax = $eachInt;\n\t\t\t\t$indexFound = $i;\n\t\t\t}\n\t\t}\n\n\t\t$arrayToSearch[$indexFound] = ($floor - 1);\n\t\t$returnArray[$retIndex] = $stringArray[$indexFound];\n\n\n\t}\n\n\treturn $returnArray;\n\t\n}<\/pre>\n<p style=\"margin-left: 40px;\">Description:<\/p>\n<p style=\"margin-left: 40px;\">This will step through a given string array ($stringArray) and sort that array based on the integer values found in $intArray.<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<p style=\"margin-left: 40px;\">Details:<\/p>\n<p style=\"margin-left: 40px;\">The return array is sorted&nbsp; in a descending order<\/p>\n<pre style=\"margin-left: 80px;\">sortStringByInts({&quot;dog&quot;, &quot;mouse&quot;, &quot;cat&quot;}, {2,0,1});\n<\/pre>\n<p style=\"margin-left: 40px;\">would return<\/p>\n<pre style=\"margin-left: 80px;\">{&quot;dog&quot;, &quot;cat&quot;, &quot;mouse&quot;}\n<\/pre>\n<p>&nbsp;<\/p>\n<h4 style=\"margin-left: 40px;\">sortObjectsByHierarchy&nbsp;<\/h4>\n<pre style=\"margin-left: 80px;\">global proc string[] sortObjectsByHierarchy(string $objectArray[])\n{\n    int $ints[] = {};\n&nbsp;&nbsp;&nbsp; for($eachObj in $objectArray) $ints[size($ints)] = countCharInString(&quot;|&quot;, $eachObj);\n\n&nbsp;&nbsp;&nbsp; return sortStringByInts($objectArray,$ints);\n}&nbsp;&nbsp;<\/pre>\n<p style=\"margin-left: 40px;\">Description:<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;Primarily a wrapper procedure that collects the hierarchy depth for each object (via &#39;countCharInString&#39;) and passes that along with the object array to the &#39;sortStringByInts&#39; procedure.<\/p>\n<p style=\"margin-left: 40px;\">Details:<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;The &quot;|&quot; character that is passed to &#39;countCharInString&#39; procedure represents a &#39;level&#39; in the hierarchy.&nbsp; The way Maya represents a long path of an object is by listing out all parents in order distguishing each object with a &quot;|&quot; or <em>pipe<\/em> character.<\/p>\n<p style=\"margin-left: 40px;\">i.e. &#39;|pCube1|pCube2|locator1&#39;<\/p>\n<p style=\"margin-left: 40px;\">which translates to &#39;locator1&#39; being a child of &#39;pCube2&#39; which is a child of &#39;pCube1&#39; which in turn is a child of the world.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<h3>Core procedures<\/h3>\n<h4 style=\"padding-left: 30px;\">&nbsp;<\/h4>\n<h4 style=\"margin-left: 40px;\">renameObjects (Modified!)<\/h4>\n<pre style=\"margin-left: 80px;\">global proc string[] renameObjects(string $unsortedObjs[], string $newName, int $padding)\n{\n\n    string $sortedObjs[] = sortObjectsByHierarchy($unsortedObjs);\n    int $mapping[] = getStringArrayMapping($unsortedObjs, $sortedObjs);\n    int $startIndex = 0;\n    string $newNamesUnsorted[] = {};\n<\/pre>\n<pre style=\"margin-left: 80px;\">\n    for($i = 0; $i &lt; size($unsortedObjs); $i++)\n    {\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; string $eachName = ($newName + &quot;_&quot; + padInt($startIndex + $i, $padding));\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; while(objExists($eachName))\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $startIndex++;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $eachName = ($newName + &quot;_&quot; + padInt($startIndex + $i, $padding));\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $newNamesUnsorted[size($newNamesUnsorted)] = $eachName;\n&nbsp;&nbsp;&nbsp; }\n\n&nbsp;&nbsp;&nbsp; for($eachIndex in $mapping)\n&nbsp;&nbsp;&nbsp; {\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $unsortedObjs[$eachIndex] = renameLong($unsortedObjs[$eachIndex], $newNamesUnsorted[$eachIndex]);\n&nbsp;&nbsp;&nbsp; }\n\n&nbsp;&nbsp;&nbsp; return $unsortedObjs;\n}&nbsp;<\/pre>\n<p style=\"margin-left: 40px;\">Description:<\/p>\n<p style=\"margin-left: 40px;\">This is the entry point for the rename routine and so it handles the main iteration over the specified objects.<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<p style=\"margin-left: 40px;\">Details:<\/p>\n<p style=\"margin-left: 40px;\">Here we have our custom built hierarchy sort routine.<\/p>\n<blockquote>\n<pre style=\"margin-left: 40px;\">string $sortedObjs[] = sortObjectsByHierarchy($unsortedObjs);<\/pre>\n<\/blockquote>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<p style=\"margin-left: 40px;\">Lets pass this newly sorted list through our string array mapper and see how it was reordered:<\/p>\n<blockquote>\n<pre style=\"margin-left: 40px;\">int $mapping[] = getStringArrayMapping($unsortedObjs, $sortedObjs);<\/pre>\n<\/blockquote>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<p style=\"margin-left: 40px;\">Now we have the mapping we can step through the mapping and process each object collecting the new name for each object and adding it to the $newNamesUnsorted string array.<\/p>\n<blockquote>\n<pre style=\"margin-left: 40px;\">for($i = 0; $i &lt; size($unsortedObjs); $i++)<\/pre>\n<\/blockquote>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<p style=\"margin-left: 40px;\">This creates a string to use for the objects new name.&nbsp; It overrides the objects name with the $newName along with given increment options<\/p>\n<pre style=\"margin-left: 80px;\">string $eachName = ($newName + &quot;_&quot; + padInt($startIndex + $i, $padding));\n<\/pre>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;This double checks that the new name we are going to assign to the object is unique in the scene (at all levels in the hierarchy)<\/p>\n<pre style=\"margin-left: 80px;\">while(objExists($eachName))\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $startIndex++;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $eachName = ($newName + &quot;_&quot; + padInt($startIndex + $i, $padding));\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<\/pre>\n<p style=\"margin-left: 40px;\">Then rename the object at the identified index and reassign it back into the original $unsortedObjs array:<\/p>\n<blockquote>\n<pre style=\"margin-left: 40px;\"> $unsortedObjs[$eachIndex] = renameLong($unsortedObjs[$eachIndex], $newNamesUnsorted[$eachIndex]);<\/pre>\n<\/blockquote>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<h3>UI procedures<\/h3>\n<h4 style=\"padding-left: 30px;\">&nbsp;<\/h4>\n<h4 style=\"margin-left: 40px;\">renameObjectsUI (Modified!)<\/h4>\n<pre style=\"margin-left: 80px;\">global proc renameObjectsUI()\n{\n\n\n    global string $renameObjectsWindow;\n    if (`window -exists $renameObjectsWindow`) deleteUI -window $renameObjectsWindow;\n&nbsp;&nbsp;&nbsp; $renameObjectsWindow = `window -widthHeight 308 100 -sizeable 0 -title &quot;Rename Objects Intermediate&quot; &quot;renameObjectsWindow&quot; `;\n&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; columnLayout;\n\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; rowColumnLayout -numberOfRows 4;\n\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; string $paddingCtrl = `intFieldGrp -numberOfFields 1\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -label &quot;Padding&quot;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -ann &quot;How much to pad integer suffix&quot;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -cw 1 90\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -cw 2 30\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -value1 2`;\n\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; string $newNameCtrl = `textFieldGrp\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -label &quot;New Name&quot;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -ann &quot;Enter new name to rename object(s) to&quot;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -cw 1 90\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -cw 2 208\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -text &quot;myObject&quot;`;\n\n\n\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setParent..;\n\n\n\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; rowColumnLayout -numberOfColumns 4\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -columnWidth 1 100\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -columnWidth 2 100\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -columnWidth 3 100;\n\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; button -l &quot;Cancel&quot; -c &quot;deleteUI -window $renameObjectsWindow;&quot;;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; button -l &quot;Defaults&quot; -c &quot;renameObjectsUI();&quot;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -ann &quot;Reset settings to defaults&quot;;\n\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; button -l &quot;Apply&quot;&nbsp;&nbsp;&nbsp; -c (&nbsp;&nbsp;&nbsp; &quot;renameObjects(getSelection(),&quot;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; +&nbsp;&nbsp;&nbsp; &quot;(&quot;&quot; + textFieldGrp(&quot;-q&quot;, &quot;-text&quot;, &quot;&quot; + $newNameCtrl +&quot;&quot;)), &quot;\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; +&nbsp;&nbsp;&nbsp; &quot;(&quot;&quot; + intFieldGrp(&quot;-q&quot;, &quot;-value1&quot;, &quot;&quot; + $paddingCtrl + &quot;&quot;)));&quot;)\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -ann&nbsp;&nbsp;&nbsp; &quot;Do rename!&quot;;\n\n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setParent..;\n\n&nbsp;&nbsp;&nbsp; showWindow $renameObjectsWindow;\n\n}&nbsp;<\/pre>\n<p style=\"margin-left: 40px;\">Description:<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;The start of a UI for renaming select objects in a scene. Albeit still simple the structure of this procedure is easy enough to extend.<\/p>\n<p style=\"margin-left: 40px;\">&nbsp;<\/p>\n<h4>Thats it!<\/h4>\n<p><a href=\"https:\/\/www.rodgreen.com\/scripts\/mel\/renameIntermediate.mel\" onclick=\"window.open(this.href,'renameIntermediate','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,status'); return false\">[Download Script]<\/a><\/p>\n<h3>Conclusions \/ next steps?<\/h3>\n<p>&nbsp;<\/p>\n<ul>\n<li>The object list that&#39;s returned from the renameObjects isn&#39;t accurate if objects in a hierarchy are renamed<\/li>\n<li>The method of referencing and updating the list of objects we are handling isn&#39;t strong enough<\/li>\n<li>Provide object type filtering options<\/li>\n<li>The current method for setting the objects name is destructive without any options for just adding a prefix or suffix<\/li>\n<li>Search and replace through selected objects or whole scene<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Check out the next stage of this tool in &quot;<a href=\"https:\/\/www.rodgreen.com\/wordpress\/?p=117\">Renaming objects in Maya (advanced)<\/a>&quot; &#8211; Coming soon!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; [Download Script] &nbsp; This is the second part to a three part tutorial on renaming objects in Maya.&nbsp; In the first installment we established a collection of procedures and a simple UI that allows multiple objects to be renamed. Some issues were identified with the methods used previously and so in this next stage [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,2,4,6,7,11,13,15],"tags":[54,42,44,56,47],"class_list":["post-80","post","type-post","status-publish","format-standard","hentry","category-animation","category-art","category-development","category-games","category-maya-art","category-technical-art","category-tools","category-tutorials","tag-maya-art","tag-rename","tag-scripting","tag-technical-art","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=\/wp\/v2\/posts\/80","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=80"}],"version-history":[{"count":0,"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=\/wp\/v2\/posts\/80\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}