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