About Me

Thursday, September 6, 2012

Lost Animation - Part2!

God how many times have I been asked for this since posting the 'Lost Animation' thread nearly a year ago now. So here's a complete and utter dirty hack for those who have requested it. Unlike the other fix code this is completely blind. You select the controllers that are no longer connected to the animation data that they should be, and this, in an ideal world, will reconnect the required animCurves for you.

There are a few HUGE expectations here, mainly that the scene is clean and that the animCurves are still consistently named against the channel they were keyed against. As I said, this is a hack but it seems to be what a lot of people are in need of.

So the expectation is that an attr on a controller called NameSpace:L_Foot.translateX should be connected to NameSpace:L_Foot_translateX, or L_Foot_translateX depending on the flag stripNamespace thats in the code.

As I said, this is a really quick hack, but I figured what the hell. Oh and if the data went through AnimLayers....sorry, you're stuffed!


import maya.cmds as cmds

#Change this to False if the curves are not in the rootNamespace but
#in the sameNamespace as the controllers.

#build up the main lists
[chns.extend(cmds.listAnimatable(node)) for node in nodes]    
for chn in chns:
    if stripNamespace:
    if animCurveExpected in animCurves:
        if not cmds.isConnected('%s.output' % animCurveExpected,chn):
            print '%s >> %s' % (animCurveExpected,chn)
            cmds.connectAttr('%s.output' % animCurveExpected,chn,force=True)