Maya Stand Alone Issue, Baking Animation

Hey, I’m currently using Maya Standalone to baked out a list of controllers on a rig and copy their animation onto a locator. When I run the script any controllers that have key frames on them will transfer over, but if a controller is constrained to an object the script will only copy the first frame of its animation. I tried running the same script in the Maya and was able to copy the animation of all controllers, constrained or not. So is there an issue with Maya Standalone that prevents it from baking out the animation of a constrained object?

If that is the case then is there a way I can store the animation of the selected controllers, I was thinking about used Maya API, but I’m not to familiar with it and not to sure exactly where to start. Any help would be much appreciate. I also thought to store the information onto an xml file, but if a rig have 50 controllers and each have 10 attributes, and there’s 100 frames in the shot, well that would just take an crazy about of time to write out and read back to the controllers and key them all for every frame. Also it doesn’t seem very efficient or practical.

The reason why I can’t just use the script in regular Maya is that I have to copy animation for several files and need a way to batch multiple files out.

I hope what I am saying makes sense, any help would be very much appreciate. Thank you.

I’m going to guess that your script interacts with UI components, and that it is failing due to their absence. For instance, how does it determine what range of frames to bake?

At first I was grabbing first and last frame from the time slider, then tried using the colon ( cmds.bakeResult( s=0, t=[:], f=[:]), but still gave me the same issue. Even though the time slider does exist it still gave me the right time ranges that i needed. Because, the other controllers in the scene baked out correctly, just the ones with the parentConstraints.

Another problem I noticed was that when I run the script in my maya it runs fine, but if I run the same code on another computer I run into the same issue of the constrained controllers staying in one position.

My next idea that I am going to try is just manual baking the controllers out. So going through, each frame getting and setting Attrs of each attribute onto a locator and setting a key. This also doesn’t seem very efficient, I figure it’s worth a shot.

Thank you for you observation though, and I will double check to see if there is something with the UI elements that is causing the script to fail.

Do the constrained controllers have anim curves in addition to a constraint? How are you referring to the anim curves? Or are you just querying the attribute data at any given frame?

A hunch that I would investigate is if you are listing connections, maybe you need to filter for the anim data. Otherwise, if it sees the constraint but not the anim curve, it might not return the correct amount of keys.

Can you post some code so we can see more specifically what you are doing?

Clesage,

Sometimes yes they do, but in this particular scene I am trying the script on they do not. Right now I’m simply trying to bake out the animation of the controller and copying the animation back onto a locator. The problem is that will the constrained controller is baked out it only the first is baked over the entire time range. So when the controller is suppose to follow whatever was constraining it, it just stays in place.

This is a quick and dirty version of my code. The overall code uses just simple maya commands, which is why I find it very odd to be having such an issue.

path= ‘animatedScene.ma’
##Open File
cmds.file( path, f=1, o=1)

path= os.path.normpath( path)
#print( path)

##Open File
cmds.file( path, f=1, o=1)

##Grab Start Frame
startTime= int( cmds.playbackOptions( q=True, min=True))
#print( startTime)

##Grab End Frame
endTime= int( cmds.playbackOptions( q=True, max=True))
print( endTime)

##Grab all sets
setList= cmds.ls( et= ‘objectSet’ )
#print( setList)

for set in setList:
ctrl_list= cmds.sets( set, q= 1)
#print( ctrl_list)

##Bake controllers from Set Lister
for ctrl in ctrl_list:
	##Bake out controls
	cmds.bakeResults( ctrl, simulation=0, t=( startTime, endTime), shape=1, dic= 0, pok= 0)

##Copy animation from controller to locator
for ctrl in ctrl_list:
	##Fix namespace
	newCtrl= ctrl.replace( ':', '_NmSp_')
	#print( newCtrl)
	
	##Create locator
	sceneAnimLoc= cmds.spaceLocator( n= newCtrl+'_animLoc', p=[0, 0, 0] )[0]
	#print( sceneAnimLoc)
	
	##Grab attributes
	attrList= cmds.listAttr( ctrl, k= 1, u= 1)
	#print( ctrl, attrList)
	
	for attr in attrList:
		newAttr= attr.replace( ':','_NmSp_')
		newAttr= newCtrl+'_'+ newAttr
		#print( newAttr)
		
		##Create attribute for locator
		cmds.addAttr( sceneAnimLoc, ln= newAttr, at= 'double', k= 1)
		
		##Check if controller attribute is keyed
		checkKey= cmds.keyframe( ctrl, q= 1, at= attr)
		#print( ctrl, attr, checkKey)
		
		if( checkKey):
			##Copy key from at Controller attribute
			cmds.copyKey( ctrl, time=[], f=[], attribute= attr)
			
			##Paste Controller Attribute onto SceneAnim Loc
			cmds.pasteKey( sceneAnimLoc, attribute= newAttr)

##Save File
cmds.file( rn= ‘baked_animScene.mb’)
cmds.file( s=1, f=1)

currentFile= cmds.file( q=1, exn=1)
print( currentFile)