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
This commit is contained in:
committed by
Sybren A. Stüvel
parent
e8c5d26838
commit
e7191f8390
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user