From e7191f8390b275b54826ea4a1e06e57e5596b289 Mon Sep 17 00:00:00 2001 From: Alberto-Luaces Date: Mon, 16 Jun 2025 15:59:48 +0200 Subject: [PATCH] Python API: update animation example in quickstart docs for slots Update the Animation example in the Python API: Quickstart documentation to use slotted Actions. Pull Request: https://projects.blender.org/blender/blender/pulls/140334 --- doc/python_api/rst/info_quickstart.rst | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/doc/python_api/rst/info_quickstart.rst b/doc/python_api/rst/info_quickstart.rst index 4e7382b9dd6..d422bd9b656 100644 --- a/doc/python_api/rst/info_quickstart.rst +++ b/doc/python_api/rst/info_quickstart.rst @@ -447,9 +447,22 @@ Using low-level functions: .. code-block:: python obj = bpy.context.object - obj.animation_data_create() - obj.animation_data.action = bpy.data.actions.new(name="MyAction") - fcu_z = obj.animation_data.action.fcurves.new(data_path="location", index=2) + + # Create the action, with a slot for the object, a layer, and a keyframe strip: + action = bpy.data.actions.new(name="MyAction") + slot = action.slots.new(obj.id_type, obj.name) + strip = action.layers.new("MyLayer").strips.new(type='KEYFRAME') + + # Create a channelbag to hold the F-Curves for the slot: + channelbag = strip.channelbag(slot, ensure=True) + + # Create the F-Curve with two keyframes: + fcu_z = channelbag.fcurves.new(data_path="location", index=2) fcu_z.keyframe_points.add(2) fcu_z.keyframe_points[0].co = 10.0, 0.0 fcu_z.keyframe_points[1].co = 20.0, 1.0 + + # Assign the action and the slot to the object: + adt = obj.animation_data_create() + adt.action = action + adt.action_slot = slot