{"id":62,"date":"2013-05-11T11:50:59","date_gmt":"2013-05-11T01:50:59","guid":{"rendered":"http:\/\/alrichardson.com\/?p=62"},"modified":"2013-08-05T19:45:21","modified_gmt":"2013-08-05T09:45:21","slug":"naming-and-renaming","status":"publish","type":"post","link":"https:\/\/alrichardson.com\/?p=62","title":{"rendered":"Naming and renaming"},"content":{"rendered":"<p>During the last job I was on, we were receiving rigs from another company.<br \/>\nThese rigs did not always match our hierarchy and naming conventions, so, part of my job was to recompile these rigs to match our conventions. One common and potentially time consuming job was the renaming of control curves.<br \/>\nWe would receive them with naming conventions along the lines of &#8216;*_Ctrl_01&#8217;, &#8216;*_Ctrl_02&#8217; and so on.<br \/>\nRenaming every control in the rig is neigh on impossible, so I wrote a script to do so!<br \/>\nThe script I wrote was smashed together with no time for optimization but now with a little time on my hands I have rewritten it to be user friendly and fast.<br \/>\nHere it is, have a look!<\/p>\n<pre class=\"lang:python decode:true  crayon-selected\">import maya.cmds as cmds\r\n\r\nselection = cmds.ls( sl = True)\r\n\r\nfor i in selection:\r\n    shape = cmds.listRelatives( i, shapes = True )\r\n    if shape == None:\r\n        print 'No shape for ' + i + ', aborting.'\r\n    else:\r\n        try:\r\n            a,b = i.split('_Ctrl')\r\n            cmds.rename( i, a + b + '_Ctrl' )\r\n        except:\r\n            print 'No Ctrl in name of ' + i<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>During the last job I was on, we were receiving rigs from another company. These rigs did not always match our hierarchy and naming conventions, so, part of my job was to recompile these rigs to match our conventions. One common and potentially time consuming job was the renaming of control curves. We would receive [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,3,5,7],"tags":[],"class_list":["post-62","post","type-post","status-publish","format-standard","hentry","category-coding","category-maya","category-python","category-tools"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=62"}],"version-history":[{"count":3,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":64,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions\/64"}],"wp:attachment":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}