{"id":211,"date":"2016-03-14T16:34:12","date_gmt":"2016-03-14T06:34:12","guid":{"rendered":"http:\/\/alrichardson.com\/?p=211"},"modified":"2016-03-14T16:34:12","modified_gmt":"2016-03-14T06:34:12","slug":"its-been-a-while","status":"publish","type":"post","link":"https:\/\/alrichardson.com\/?p=211","title":{"rendered":"Its been a while.."},"content":{"rendered":"<p>I&#8217;ve been knuckled down with working full time! But its time to get back onto this blogging business.<br \/>\nStarting with revisiting an old tool feels appropriate!<br \/>\nHaving written a tool for upsaving your scene some years ago<br \/>\nI&#8217;ve since learned a lot about string formatting and array navigation in Python.<br \/>\nThe tool is simple, it finds out where your current scene is located and its name,<br \/>\nthen looks for a number at the end of the name, adds 1 to it and saves the file, with the new name in<br \/>\nthe same directory.<\/p>\n<pre class=\"lang:python decode:true \" >def upSaveScene():\r\n\tcurrentFileLocation = cmds.file( query = True, location = True )\r\n\tcurrentFileName = currentFileLocation.split( '\/' )[-1]\r\n\tif '.mb' in currentFileName:\r\n\t\tstripExtension = currentFileName.replace('.mb','')\r\n\tif '.ma' in currentFileName:\r\n\t\tstripExtension = currentFileName.replace('.ma','')\r\n\tversionNumberString = stripExtension.split( '_' )[-1]\r\n\tif versionNumberString.isdigit():\r\n\t\tversionNumber = int(versionNumberString)\r\n\t\tnewVersionNumber = versionNumber + 1\r\n\t\tnewFilename = currentFileName.replace( str(versionNumber), str(newVersionNumber) )\r\n\tif not versionNumberString.isdigit():\r\n\t\tnewFilename = stripExtension + '_01'\r\n\tnewFilenamePath = currentFileLocation.replace( currentFileName, newFilename )\r\n\t\r\n\tcmds.file( rename = newFilenamePath )\r\n\tcmds.file( save = True, f = True )<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been knuckled down with working full time! But its time to get back onto this blogging business. Starting with revisiting an old tool feels appropriate! Having written a tool for upsaving your scene some years ago I&#8217;ve since learned a lot about string formatting and array navigation in Python. The tool is simple, it [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-211","post","type-post","status-publish","format-standard","hentry","category-maya"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/211","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=211"}],"version-history":[{"count":1,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":212,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions\/212"}],"wp:attachment":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}