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!

Mark

import maya.cmds as cmds
nodes=cmds.ls(sl=True,l=True)
chns=[]

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

#build up the main lists
animCurves=cmds.ls(type='animCurve',s=True)
[chns.extend(cmds.listAnimatable(node)) for node in nodes]    
    
for chn in chns:
    if stripNamespace:
        animCurveExpected=chn.split(':')[-1].split('|')[-1].replace('.','_')
    else:
        animCurveExpected=chn.split('|')[-1].replace('.','_')
    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)

13 comments:

  1. OOOOOOOOOWESOME! My animation is back! I changed the stripNamespace to False and that was it! AWESOMEEEEEEEEEEEE!! Thanks so much Mark!

    ReplyDelete
  2. I'm curious, what build of Maya are you running? As far as I know this bug has been quashed, we've certainly not had any reports of people round the studio suffering from it and most of the animators are on 2012 now.

    ReplyDelete
    Replies
    1. I’m using 2012 whit no hot fix, is weird because it has happened quite a lot here, I don’t know if the rig is set up in a certain way that makes the bug more likely to happen.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This just saved my shot!! Thanks man.

    ReplyDelete
  5. 2013 and I´m still having this problem, I´m using maya 2012. But how can I prevent this to keep happening, I´m sooo frustrated

    ReplyDelete
  6. I guess it all depends on your setup really. The main bug that was causing this has been fixed, are you saving as ma's or mb's?

    ReplyDelete
  7. MarkJ I can't thank you enough! You just saved my day!! I had this issue on Maya 2018. Thank you so much!!

    ReplyDelete
    Replies
    1. Wow, been a few years since I wrote this stuff, glad it's still coming in useful!

      Delete
    2. This comment has been removed by the author.

      Delete
  8. This comment has been removed by the author.

    ReplyDelete