ActionSlot(bpy_struct)
Action Slots organize animation data within an action. Each action has slots with specific animation data. An animated data-block specifies an action and a slot, determining the animation data it uses. See the Blender Manual for how Action Slots are used, or the technical documentation for details on the animation system’s architecture.
Create & Access an Action Slot
To get started with Action Slots, you can easily create them by inserting a keyframe on an object. When you do this, Blender automatically creates an Action & Slot for that data-block.
import bpy
# Assume Suzanne mesh is present in the scene.
suzanne = bpy.data.objects["Suzanne"]
# Create animation data and an action for Suzanne:
# Slot will be automatically created.
suzanne.keyframe_insert("location", index=0)
# Action slots can be accessed like this:
action = suzanne.animation_data.action
for slot in action.slots:
print(f"Slot Identifier {slot.identifier!r} "
f"with name {slot.name_display!r} "
f"targets ID type {slot.target_id_type!r}")
Manually Create an Action Slot
If required you can also manually create Action Slots on an Action. Note the target_id_type
that matches the data-block type. Identifiers start with a prefix based on the ID type,
e.g. “OB” for objects, followed by the name. There can be identifiers like OBSuzanne
and MESuzanne and the name (Suzanne) can be shared between them. This is intentional,
so that the slots and the datablocks can have the same name.
# Actions creation.
action = bpy.data.actions.new("SuzanneAction")
# Creation of slots requires an ID type and a name.
slot = action.slots.new(id_type='OBJECT', name="Suzanne")
print(f"slot type={slot.target_id_type!r} "
f"name={slot.name_display!r} "
f"identifier={slot.identifier!r}")
# Output:
# slot type=OBJECT name=Suzanne identifier=OBSuzanne
Explicitly Assigning Action Slots
An action slot is compatible with a data-block if the slot’s target_id_type matches the data-block’s type.
If there are multiple slots on the Action, and you want to just pick the first one that’s
compatible, use the following code. anim_data.action_suitable_slots can be used after the
Action has been assigned; it is a list of action slots of that Action, but only the ones that
are actually compatible with the owner of anim_data (in this case, Suzanne).
# If there are multiple slots on the Action, pick the first one that's compatible
anim_data = suzanne.animation_data_create()
anim_data.action = action
assert anim_data.action_suitable_slots, "expecting at least one suitable slot"
anim_data.action_slot = anim_data.action_suitable_slots[0]
Finding Action Slot Users
To return a list of the data-blocks that are animated by a specific slot of an Action, use the users() method of the ActionSlot.
# Iterate through all actions in the Blender data.
print("Action & slot users:")
for action in bpy.data.actions:
for slot in action.slots:
# Return the data-blocks that are animated by this slot of this action
users = slot.users()
print(f"{action.name:20} slot={slot.identifier:12s} users: {users}")
base class — bpy_struct
- class bpy.types.ActionSlot(bpy_struct)
Identifier for a set of channels in this Action, that can be used by a data-block to specify what it gets animated by
- active
Whether this is the active slot, can be set by assigning to action.slots.active
- Type:
boolean, default False, (readonly)
- handle
Number specific to this Slot, unique within the Action. This is used, for example, on a ActionKeyframeStrip to look up the ActionChannelbag for this Slot
- Type:
int in [-inf, inf], default 0, (readonly)
- identifier
Used when connecting an Action to a data-block, to find the correct slot handle. This is the display name, prefixed by two characters determined by the slot’s ID type
- Type:
string, default “”, (never None)
- name_display
Name of the slot, for display in the user interface. This name combined with the slot’s data-block type is unique within its Action
- Type:
string, default “”, (never None)
- select
Selection state of the slot
- Type:
boolean, default False
- show_expanded
Expanded state of the slot
- Type:
boolean, default False
- target_id_type
Type of data-block that this slot is intended to animate; can be set when ‘UNSPECIFIED’ but is otherwise read-only
ACTIONAction.ARMATUREArmature.BRUSHBrush.CACHEFILECache File.CAMERACamera.COLLECTIONCollection.CURVECurve.CURVESCurves.FONTFont.GREASEPENCILGrease Pencil.GREASEPENCIL_V3Grease Pencil v3.IMAGEImage.KEYKey.LATTICELattice.LIBRARYLibrary.LIGHTLight.LIGHT_PROBELight Probe.LINESTYLELine Style.MASKMask.MATERIALMaterial.MESHMesh.METAMetaball.MOVIECLIPMovie Clip.NODETREENode Tree.OBJECTObject.PAINTCURVEPaint Curve.PALETTEPalette.PARTICLEParticle.POINTCLOUDPoint Cloud.SCENEScene.SCREENScreen.SOUNDSound.SPEAKERSpeaker.TEXTText.TEXTURETexture.VOLUMEVolume.WINDOWMANAGERWindow Manager.WORKSPACEWorkspace.WORLDWorld.UNSPECIFIEDUnspecified – Not yet specified. When this slot is first assigned to a data-block, this will be set to the type of that data-block.
- Type:
enum in [
'ACTION','ARMATURE','BRUSH','CACHEFILE','CAMERA','COLLECTION','CURVE','CURVES','FONT','GREASEPENCIL','GREASEPENCIL_V3','IMAGE','KEY','LATTICE','LIBRARY','LIGHT','LIGHT_PROBE','LINESTYLE','MASK','MATERIAL','MESH','META','MOVIECLIP','NODETREE','OBJECT','PAINTCURVE','PALETTE','PARTICLE','POINTCLOUD','SCENE','SCREEN','SOUND','SPEAKER','TEXT','TEXTURE','VOLUME','WINDOWMANAGER','WORKSPACE','WORLD','UNSPECIFIED'], default'UNSPECIFIED'
- target_id_type_icon
- Type:
int in [-inf, inf], default 0, (readonly)
- users()
Return the data-blocks that are animated by this slot of this action
- Returns:
users
- Return type:
- duplicate()
Duplicate this slot, including all the animation data associated with it
- Returns:
Duplicated Slot, The slot created by duplicating this one
- Return type:
- classmethod bl_rna_get_subclass(id, default=None, /)
- Parameters:
id (str) – The RNA type identifier.
- Returns:
The RNA type or default when not found.
- Return type:
bpy.types.Structsubclass
- classmethod bl_rna_get_subclass_py(id, default=None, /)
- Parameters:
id (str) – The RNA type identifier.
- Returns:
The class or default when not found.
- Return type:
type