Animations are stored in function curves (FCurves). FCurves contain keys to define a value in an assigned time. Usually, many FCurves (x, y, and z) belong to one FCurveNode.
The FCurveNodes map to the properties of an object. An object has both animatable and non-animatable properties. You can edit the animatable properties of an object by modifying the corresponding FCurves. In the UI, the function curves appear in the FCurves tab when you select an animatable property in the Property list.
To edit the animation, you need to modify the FCurves and keys. In animation using SDK scripting, you need to consider the FCurveNode, FCurve, and key three levels.
The following sections explain how to use the SDK to perform simple animation tasks. To follow the instructions, download the files and scripts from http://area.autodesk.com/downloads/scripts/motionbuilder-animation-scripts.
Run the create_animation_on_cube.py script in the Python Editor to get a simple FCurve.
Following are the points to keep in mind:
KeyAdd()
– Adds a key with an assigned value in an assigned time.SetCandidate()
– Changes the value in the current time but does not key it, until KeyCandidate()
is executed.KeyCandidate()
– Adds the key with the candidate value in the current time.Keep the last scene open, and then run the copy_animation.py
script to copy the animation from the Cube and create a new cube called DST.
Following are the points to keep in mind:
FBFindModelByLabelName()
– Finds a model by name.lDstNode.FCurve.KeyReplaceBy(lSrcNode.FCurve)
– Replaces the keys in the destination FCurve with the source FCurve.Keep the last scene open, select the DST object, and run the clear_animation.py
script to clear the selected animation.
Following are the points to keep in mind:
pNode.FCurve.EditClear()
– Clears all the keys in the FCurve.FBGetSelectedModels()
– Gets all the selected models.