Sub topic 1
From Keyframes to Actions: Where Animation Data Lives
Prerequisites
This chapter assumes that you can navigate the 3D Viewport, insert keyframes with I, use the Timeline or Dope Sheet, and understand object location, rotation, and scale.
The animation data hierarchy
When you insert a keyframe, Blender stores more than a dot on the Timeline. The data follows a hierarchy:
- An object has animation data when it contains keyframed or driven properties.
- The animation data points to an action.
- An action contains one or more F-curves.
- Each F-curve contains keyframe points that describe values at specific frames.
An action is a reusable container for an animation. For example, a character might have actions named Walk, Jump, and Idle. An action can contain separate curves for location, rotation, scale, shape keys, and many other properties.
What an F-curve stores
An F-curve maps one property value to time. The horizontal axis is the frame, and the vertical axis is the property value. A curve for an object's X location might contain these values:
| Frame | X location |
|---|---|
| 1 | 0.0 |
| 24 | 4.0 |
The curve does not usually store a value for every frame. Blender calculates the values between keyframes using interpolation. The curve for X location is separate from the curves for Y location and Z location.
This separation matters. An object's location property is a three-value array, but it normally uses three F-curves:
location, array index0: Xlocation, array index1: Ylocation, array index2: Z
Rotation and scale use the same pattern. A property such as visibility may use only one curve.
Creating and inspecting an action
The following script creates two location keyframes, then prints the action and its F-curves. Run it with an object active.
import bpy
obj = bpy.context.object
if obj is None:
raise RuntimeError("Select an object before running this script.")
obj.location = (0.0, 0.0, 0.0)
obj.keyframe_insert(data_path="location", frame=1)
obj.location = (4.0, 0.0, 0.0)
obj.keyframe_insert(data_path="location", frame=24)
action = obj.animation_data.action
print("Action:", action.name)
for fcurve in action.fcurves:
print(
"Path:", fcurve.data_path,
"Index:", fcurve.array_index,
"Keys:", len(fcurve.keyframe_points),
)The script creates curves for all three location components. Even though Y and Z remain at zero, Blender can still create keyframes for those components because the complete location property was inserted.
Actions and the Graph Editor
The Graph Editor displays the F-curves from the active animation context. Selecting an object usually shows its active action. Selecting a different object changes the available channels.
An action can be assigned to another compatible object, but the data paths must make sense for that object. A curve targeting location is generally portable. A curve targeting a custom property or a bone may require matching data on the destination.
Exercise
Exercise
An action has an F-curve with data path "location" and array index 0. Which value does it control?
Show answer
It controls the object's X location over time.