Sub topic 1
From keyframes to actions: where animation data lives
When you press I over a property, Blender does more than remember a number at a frame. It builds a small chain of data blocks, and the Graph Editor is a view onto the end of that chain. This chapter follows the chain from the object down to the individual keyframe, so that later chapters on curves, handles and modifiers have somewhere to attach.
Prerequisites
This chapter assumes you can:
- Move around the 3D Viewport and select objects.
- Insert keyframes with I or from the Timeline and Dope Sheet.
- Play back animation with the Timeline controls.
- Read basic object properties such as location, rotation and scale.
The Python examples are optional. They run in the Scripting workspace's Python console or Text Editor and use the bpy module that ships with Blender.
What a keyframe actually records
A keyframe is a pair: a frame number and the value of one property at that frame. Blender interpolates the values between keyframes, so the motion between them is calculated, not stored.
One detail matters later. A keyframe belongs to a single number, not to an object. Location is three numbers (X, Y, Z), so keying location creates three separate series of keyframes. By default, I keys all three together, and you can also key one component by right-clicking a single field and choosing Insert Single Keyframe.
The chain: object, animation data, action
Animation is stored in layers. Each layer has one job.
Each level has a distinct role:
| Level | Python access | Role |
|---|---|---|
| Animation data (AnimData) | `obj.animation_data` | A small per-ID block that says which action the object currently plays. It also holds drivers and the NLA tracks. |
| Action | `obj.animation_data.action` | A standalone data block that stores the animation. Several objects can use it. |
| F-curve | `action.fcurves` | One curve for one property component, identified by a data path and an array index. |
| Keyframe point | `fcurve.keyframe_points` | One frame/value pair, plus interpolation and handle settings. |
The important consequence is that the object does not own the keyframes. The action does. The object only points at the action. That is why you can unlink an action, swap it for another, or reuse it on a second object.
Actions are data blocks
An action is a data block, like a mesh or a material. Three behaviors follow from this.
Actions have names and user counts
When you first key an object named Cube, Blender creates an action named CubeAction and assigns it. The Dope Sheet's Action Editor mode shows this action in a data block selector in its header. From there you can rename it, assign a different one, create a new one, or unlink it.
The number next to the name is the user count. It tells you how many things reference the action.
Actions can be shared
If you make a linked duplicate with Alt+D, the copy uses the same action. Editing the curves on one object changes the other. A normal duplicate with Shift+D may copy the action instead, depending on the Duplicate Data settings in Preferences, under Editing. If two objects move together and you did not intend that, check the user count on the action.
Unused actions can be lost
Blender removes data blocks with zero users when you save and reload. If you unlink an action, or replace it with another, the old one stays in the file only until the next save and reload. Two ways to keep it:
- Click the shield icon (Fake User) next to the action name.
- Push the action down into the NLA as a strip.
Where the Graph Editor fits
The Graph Editor does not hold animation data of its own. It displays the F-curves of the actions on the selected objects, and it edits them in place. The Dope Sheet shows the same data as rows of keyframe diamonds, and the Timeline shows a reduced version of it. Editing in one editor changes what the others display, because all three read the same action.
By default, the Graph Editor lists only channels belonging to selected objects. If your curves seem to be missing, the cause is often that nothing is selected, or that the Only Show Selected filter in the header is on while the object is deselected.
Inspecting the chain from Python
The best way to confirm that the model above is real is to build it and print it. This script keys a location animation on the active object and then walks down the chain. It uses action.fcurves, which applies to Blender versions before the slotted-actions change. Check the API docs for your version.
import bpy
obj = bpy.context.object
# Before any keyframe exists, a new object usually has no animation data.
print("Before:", obj.animation_data)
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)
anim = obj.animation_data
action = anim.action
print("Action:", action.name, "users:", action.users)
for fcurve in action.fcurves:
frames = [kp.co[0] for kp in fcurve.keyframe_points]
values = [kp.co[1] for kp in fcurve.keyframe_points]
print(fcurve.data_path, fcurve.array_index, frames, values)For a new object, the output looks like this:
Before: None
Action: CubeAction users: 1
location 0 [1.0, 24.0] [0.0, 4.0]
location 1 [1.0, 24.0] [0.0, 0.0]
location 2 [1.0, 24.0] [0.0, 0.0]Three observations:
animation_dataisNoneuntil the first keyframe. Code that readsobj.animation_data.actionwithout checking will fail with anAttributeErroron an object that has never been animated.- A single
keyframe_insert(data_path="location")created three F-curves, one for each array index. Only index 0 changes, but Y and Z are keyed too. - Each keyframe point's
cois a(frame, value)pair.
To key only the X component, pass the index:
obj.keyframe_insert(data_path="location", index=0, frame=1)A note on newer Blender versions
Blender 4.4 introduced slotted actions. An action can then hold animation for several data blocks, each in its own slot, and the F-curve lists move into layers and strips inside the action. The object-to-action link and the data path and array index model stay the same, but the exact Python path to the F-curves differs from the code above. If action.fcurves is missing in your version, look up the slotted-action section of the Python API reference for the equivalent. The concepts in this chapter apply either way.
Common mistakes
- Editing a shared action by accident. You tweak one object's curve and another object changes too. Check the action's user count in the Action Editor, and use the number button next to the name to make a single-user copy.
- Losing an action after unlinking. See the warning above. Use the fake user.
- Expecting keyframes on the object's transform. The keyframes live on the action. If you clear the object's animation data, the transform values keep whatever they last evaluated to, but the motion is gone.
- Assuming one keyframe is one F-curve. Vector properties produce one F-curve per component. Colors have four, and a quaternion rotation has four.
- Missing channels in the Graph Editor. Turn off Only Show Selected, or select the object. Also check for hidden channels, which a later chapter covers.
Checking what you learned
Exercise
You key the location of a cube at frames 1 and 24 with a single press of I over the Location field. How many F-curves does the cube's action contain, and what identifies each one?
Show answer
Three. Each is identified by the data path "location" plus an array index: 0 for X, 1 for Y and 2 for Z. Each curve has two keyframe points, at frames 1 and 24.
Exercise
You make a linked duplicate of an animated object with Alt+D and then edit a keyframe on the copy in the Graph Editor. The original object's motion also changes. Why, and how do you give the copy its own animation?
Show answer
A linked duplicate shares the same action, and the keyframes live in the action rather than in the object. Editing the action's F-curves changes every object that uses it. To separate them, click the user-count number next to the action name in the Action Editor to create a single-user copy for the duplicate.
Exercise
A script runs obj.animation_data.action.name on a freshly added cube and raises an AttributeError. What is wrong, and what is a safe way to write the check?
Show answer
A new object has no animation data until its first keyframe, so obj.animationdata is None. Check it first, for example: if obj.animationdata and obj.animationdata.action: print(obj.animationdata.action.name).