bakeResults issues

128 views
Skip to first unread message

yann19

unread,
Aug 16, 2018, 3:10:39 PM8/16/18
to Python Programming for Autodesk Maya
I have an object that has constrained channels (translateXYZ and rotateXYZ), I set the blendParent to a value of 1 at a specified frame, while setting it to 0 for its first key of animation. Between these 2 blendParents, I have set them into 'step' mode.
This is so that, I can extend the animation, eg. from RigB to RigA.

Intitially, I tried using a quick bake script to do the channels baking, in which you select the channels in the channel box > run the script in which it will bake and set keyframe onto each frame. The curves looks smooth, no big jump in any of the translation/ rotation channels found.
And so I tried to use the same code portion and implemented into my tool.

However, for some reasons, I am not achieving the same result.
1. It is not setting any keyframes (the channels are still highlighted in green).
2. There is a big jump in the curves of 1-2 channels at the frame where I set `blendParent` and the next.

Here is the code - https://pastebin.com/p9n120bx

Could anyone kindly take a look?
Message has been deleted

yann19

unread,
Aug 16, 2018, 7:06:35 PM8/16/18
to Python Programming for Autodesk Maya
If I use the following MEL command:

global proc bakeAnimation()
{
    for ($bone in `ls -sl`)
    {
        bakeResults -t (`playbackOptions -q -min` + ":" + `playbackOptions -q -max`) -sm true -hi both -at t -at r $bone ;
    }
}
bakeAnimation()


It is able to bake in the channels at each frame and at the same time, changing those 'green' channels into 'red'. However the process does takes quite some time for it to finish iterating over it.

Even so, when using the same command but converted into Python, I am not getting the same results as compared to the MEL commands at all. 'Green' channels still remains as 'green'..

yann19

unread,
Aug 16, 2018, 8:03:57 PM8/16/18
to Python Programming for Autodesk Maya
I have created a test case:

names = ['A01', 'A02', 'B01', 'B02']


def test_bakeResults(test_grp):
   
if test_grp == 'A':
        loc01_name
= names[0]
        loc02_name
= names[1]
   
else:
        loc01_name
= names[2]
        loc02_name
= names[3]
       
    loc01
= cmds.spaceLocator(name=loc01_name)
    cmds
.setKeyframe(loc01)
   
    loc02
= cmds.spaceLocator(name=loc02_name)
    cmds
.parentConstraint(loc02, loc01)
    cmds
.currentTime(1)
    cmds
.setKeyframe('{0}.translateZ'.format(loc02_name))
    cmds
.currentTime(10)
    cmds
.move(5, z=True)
    cmds
.setKeyframe('{0}.translateZ'.format(loc02_name))
   
   
if test_grp == 'A':
        cmds
.bakeResults(
           
'|{0}'.format(loc01_name),
            simulation
=True,
            time
=(3, 5),
            preserveOutsideKeys
=True
       
)
        cmds
.group(loc02_name, loc01_name, name='python')
   
else:        
       
from maya import mel
        mel
.eval('bakeResults -t (3+ ":" + 5) -sm true -hi both -at tz {0}'.format(loc01_name))
        cmds
.group(loc02_name, loc01_name, name='mel')


test_bakeResults
('A')
test_bakeResults
('B')

In the above test case, check out both `A01` and `B01` and I am trying to get `B01` scenario.

Reply all
Reply to author
Forward
0 new messages