Thursday, July 14, 2011

"Lost Animation when loading Referenced Rigs" by Mark Jackson

Here is a really good read for anyone animating in Maya. Mark Jackson has descrived a good work through for solving this annoying problem when animating via file referencing!

"This is Particularly relevant to referenced Rigs which have characterSets.

So this has come up a few times on the forums and I've also had emails asking how to fix it so thought I'd drop some info up here. The issue is that at some point the referenceEdits that connect Animation Data to a referenced rig can get broken or corrupted. This means you can be animating away all day, saving incrementals as you go, completely unaware that when you load this scene in, all animation will be lost..or so it would seem.

see this post recently:
http://forums.cgsociety.org/showthread.php?f=7&t=990314

The issue is usually the referenceEdits themselves. What sometimes happens is that the 'connectAttr' block in the referenceEdits gets blanked. We have no idea why, neither does Autodesk, it's completely random. Its also more common on files that came from 2010 and have been loaded in 2011. It also was an issue with rigs that had characterSets on the early release of 2011 IF you were using AnimLayers. (pre hotfix2)

So what to look for?

If you open up the Reference Editor then go to file>referenceEdits. In there you should get a list of all the edits performed since that file was initially referenced in. It's basically a macro that the file load uses to reconstruct the file. So, take a look in the list, see if you still have a large 'connectAttr' block. These should be the connections from the characterSet (placeholder list) to the anim curves themselves. If these edits get corrupted then as I said, you can spend all day saving incremental saves which are all broken but you wouldn't have been aware of them until you reloaded the scenes and the reference list got re-passed.

Now there are some good things to help you. Firstly the fact that the connections aren't there doesn't mean that there's no link from the anim curves to the reference. What happens is that the curves will be left connected to the references RN reference node. If you graph the referenceNode in the hypershade you should still see the connected anim data. It's what happens when you unload a reference, the anim data is cast back to the referenceNode for safe keeping.

So, graph the data, see if it's there, look at the referenceEdit list, see if it is correct or not. If you have no 'ConnectAttrs' then its the same issues we have.

Fixing it is a different issue. Basically we need to write a little tool which spins through the characterSet plugs, then the animCurves left connected to the RN node, does a nameMatch, then reconnects the data. The following dropped into a Python script Tab should do it, just select the characterSet you want reconnected!"
  1. import pymel.core as pm  
  2. import maya.cmds as cmds  
  3. cSet,type=pm.ls(sl=True,st=True)  
  4. refNode=cSet.referenceFile().refNode  
  5.   
  6. if not type=='character':  
  7.    raise StandardError('You must select a CharacterSet to reconnect')  
  8. if not refNode:  
  9.    raise StandardError('Given characterSet is not from a referenced file')  
  10.   
  11. animCurves=refNode.listConnections(type='animCurve',s=True)  
  12. cSetPlugs=pm.aliasAttr(cSet,q=True)  
  13.   
  14. for plug in cSetPlugs[::2]:  
  15.    for anim in animCurves:  
  16.        if anim.split(':')[-1].endswith(plug):  
  17.            print '%s >> %s' % (anim,plug)  
  18.            pm.connectAttr('%s.output' % anim,'%s.%s' % (cSet,plug),force=True)