Thursday, January 31, 2013

TDs to the rescue

If you've ever opened up maya and had reference errors and no animation in your scene, grab your keyable nodes and try this (in a python window). Mark's script and blog post can be found here:






 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=False
 
#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)

No comments: