I have used bakeResults in maya.standalone without issue on parent/
point/orient constrained attributes, so I know it can work (I know
that doesn't help much).
Is the animation not baking for the full range on the constrained
attributes? Or is it just not copying for the full range?
Re your concern with XML:
"Not only to mention if there are 200 controllers in the scene I would
have to go frame by frame for each controller and their attribute and
save the data out"
The keyframe command can query an entire animation curve, so assuming
you have a list of the attributes you wanted to query for a given
object:
obj = 'locator1'
attrs = ['tx', 'ty', 'tz']
for attr in attrs:
# When querying time and value (tc/vc), the command returns a list
# of [time, value, time, value, time, value, ...]
keys = cmds.keyframe(obj, q=True, at=attr, t=[], vc=True, tc=True)
Unfortunately if you pass it a list of attributes maya doesn't
distinguish between them in the resulting list so as far as I know you
have to do it one attribute at a time.
Assuming you're doing this to baked keys, you don't need to worry
about tangents, but if you weren't you would have to use
cmds.keyTangent as well for the weight/angle/type of each tangent. I'm
not saying you should necessarily go down this route, just that it's
not as cumbersome as you seem to have assumed.
On May 30, 12:03 pm, Carlo <[email protected]> wrote:
> Hey Justin,
>
> 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.
>
> It's not that I wouldn't be able to directly use data from the XML it's
> just that it would take time to load to the data back onto the controllers
> every time the animation is updated. Not only to mention if there are 200
> controllers in the scene I would have to go frame by frame for each
> controller and their attribute and save the data out. It just doesn't seem
> very efficient.
>
> 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.
>
> import sys, os.path
> import maya.standalone as st
>
> ##Start Maya Standalone
> st.initialize(name='python')
>
> import maya.cmds as cmds
>
> 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)
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe