Sub topic 15
Actions and the Action Editor
This chapter assumes you can insert keyframes on object properties, read the Dope Sheet's channel list, and select and move keyframes. It covers where those keyframes are stored, how to inspect that storage, and the errors people most often make with it.
What an action is
When you insert the first keyframe on an object, Blender creates a data-block called an action. A data-block is a named, reusable unit of data stored in the .blend file, like a mesh or a material. An action holds a set of F-curves. Each F-curve stores the keyframes for one animated property channel, such as Z Location or X Rotation.
An action does not belong to the object that uses it. The object holds a reference to the action, in its animation data. This has three consequences:
- Several objects can share one action, and they then move identically.
- One object can switch between several actions, for example "Idle" and "Walk".
- An action can exist with no user at all, in which case Blender deletes it when you save and reload, unless you protect it (see below).
An F-curve is identified by a data path and an array index. Location is stored as the data path location with index 0, 1, or 2 for X, Y, and Z. This is the same data_path string you pass to keyframe_insert() in Python.
The Action Editor
The Action Editor is a mode of the Dope Sheet editor. It shows the keyframes of one action, the one assigned to the active object. Switch to it with the mode drop-down at the left of the Dope Sheet header, then choose Action Editor.
The header of the Action Editor contains the controls for the action data-block:
| Control | What it does |
|---|---|
| Action drop-down (browse) | Lists the actions in the file. Choosing one assigns it to the active object. |
| Name field | Renames the action. |
| New (duplicate icon) | Makes a copy of the current action and assigns the copy. |
| Fake User (shield icon) | Keeps the action in the file even when no object uses it. |
| Unlink (X) | Removes the action from the object without deleting it. |
| Push Down / Stash | Moves the action into the NLA editor for layering, covered outside this chapter. |
The channel list on the left works as it does in the Dope Sheet, but only for the one action. This makes the Action Editor useful when you want to see all of an object's animation without the clutter of other selected objects.
Naming and the default name
Blender names a new action after the object, for example CubeAction. If you animate several objects, each gets its own action with a default name, and these names are easy to confuse later. Rename actions as soon as they matter. A name like Cube_Rise tells you what you will get when you pick it from the browse list.
Creating, switching, and reusing actions
To create a second action for the same object, press the New button in the Action Editor header. Blender duplicates the current action and assigns the copy. The old action now has no user. Its name shows a 0 in the browse list, which is the user count.
To reuse an action on another object:
- Select the second object and make it active.
- Open the Action Editor.
- Pick the existing action from the browse drop-down.
Both objects now share the action, and the browse list shows a user count of 2. Editing keyframes for one object changes both. To make them independent, press the user count number next to the name. This makes a single-user copy for the active object.
The shared action only works when the properties match. An F-curve for location applies to any object, but an F-curve for a modifier or bone applies only where that data path exists. Curves that cannot be resolved appear red-underlined in the channel list.
Orphan actions and the Fake User
Blender removes data-blocks with no users when you save and reopen the file. This is the most common way people lose animation. If you switch an object to another action, or unlink an action, the first action drops to zero users and will be purged.
To prevent this, click the Fake User shield next to the action name. The shield becomes highlighted, and the action counts as having one user even when no object uses it. Enable it for every action you want to keep as a spare.
Inspecting an action from the Dope Sheet
In the normal Dope Sheet mode, the channel list shows the action under the object, with its F-curves grouped. The groups, such as Object Transforms, are created automatically when you key from the 3D Viewport. F-curves created from Python with keyframe_insert are grouped the same way unless you pass the group argument.
You can read the same structure in code. This script prints every F-curve of the active object's action, with its key count and frame range:
import bpy
obj = bpy.context.active_object
anim = obj.animation_data
if anim is None or anim.action is None:
print("No action on", obj.name)
else:
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]
print(
fcurve.data_path,
fcurve.array_index,
len(frames),
"keys",
(min(frames), max(frames)) if frames else None,
)This uses the fcurves collection of Blender 2.8 through 4.x. Newer versions with layered actions may organize F-curves differently, so check the release notes of your version if the attribute is missing.
Common errors
- Animation vanishes after reopening the file. The action had zero users. Enable the Fake User shield.
- Changing one object moves another. They share an action. Check the user count in the Action Editor and make a single-user copy.
- Keyframes appear to be missing in the Action Editor. The active object has a different action, or none. The Action Editor shows only the active object's action.
- A new action is empty after pressing New. New duplicates the current action. If the object had no action, you get an empty one, and you must insert keyframes to fill it.
- Red channel names. The F-curve's data path does not exist on the object, for example after renaming a bone or removing a modifier.
Where this leads
The action is the container for F-curves, and the Graph Editor is where you edit those curves directly. The next chapter moves from the Dope Sheet's rows of keyframes to the curves they define.
Exercise
You animate a cube, then in the Action Editor you press New to make a variation. You save the file, close it, and reopen it. The original action is gone. Why, and how do you prevent it?
Show answer
Pressing New duplicates the action and assigns the copy to the cube. The original action then has zero users. Blender does not save data-blocks with zero users, so the original was purged. Click the Fake User shield on the original action (select it from the browse list, then enable the shield) before saving.
Exercise
Two objects share one action and you want the second object to move differently without losing the shared animation on the first. What do you do in the Action Editor?
Show answer
Make the second object active, open the Action Editor, and click the user count number next to the action name. This creates a single-user copy assigned to the second object. You can then edit it without affecting the first object.