{"id":266,"date":"2018-03-31T06:01:30","date_gmt":"2018-03-30T20:01:30","guid":{"rendered":"http:\/\/alrichardson.com\/?p=266"},"modified":"2018-03-31T06:23:06","modified_gmt":"2018-03-30T20:23:06","slug":"reconnecting-with-lost-animation","status":"publish","type":"post","link":"https:\/\/alrichardson.com\/?p=266","title":{"rendered":"Reconnecting with lost animation"},"content":{"rendered":"<p>Occasionally an animator will be working away in their scene, when a new rig is published. Usually this isn&#8217;t an issue and the animator will reload the rig and have it available in their scene.<br \/>\nBut every now and then, someone doesn&#8217;t have their coffee in the morning and instead will load in the new rig, unload the old, save their work and -shock!- their animation is gone! having saved their work they cannot see a way to retrieve it.<br \/>\nAt this point I tend the hear &#8220;Aaall, my animation has broken!&#8221;<br \/>\nTalking to them and having a look at their scene it is apparent what has happened.<br \/>\nUpon loading a new rig, the animation is not connected to it, and when unloading the old rig the animCurve nodes are disconnected from the rig controls.<br \/>\nFortunately the solution to this is simple.<\/p>\n<p>1. find all animCurve nodes.<br \/>\n2. discern what control node it was connected to.<br \/>\n3. reconnect the animCurve node to the newly discerned control node.<\/p>\n<p>I&#8217;ve attached some simple code below that demonstrates this process.<\/p>\n<pre class=\"lang:python decode:true \" >import maya.cmds as cmds\r\n\r\nanimCurves = cmds.ls(type='animCurve')\r\nnameSpace = 'CH'\r\n\r\nfor animCurve in animCurves:\r\n    attr = animCurve.split('_')[-1]\r\n    control = (animCurve.replace(attr,''))[0:-1]\r\n    try:\r\n        if nameSpace:\r\n            cmds.connectAttr('%s.output' % animCurve, '%s:%s.%s' % (nameSpace, control, attr))\r\n        if not nameSpace:\r\n            cmds.connectAttr('%s.output' % animCurve, '%s.%s' % (control, attr))\r\n    except:\r\n        print 'could not connect %s' % animCurve<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Occasionally an animator will be working away in their scene, when a new rig is published. Usually this isn&#8217;t an issue and the animator will reload the rig and have it available in their scene. But every now and then, someone doesn&#8217;t have their coffee in the morning and instead will load in the new [&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-266","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\/266","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=266"}],"version-history":[{"count":6,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions"}],"predecessor-version":[{"id":272,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions\/272"}],"wp:attachment":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}