No changes from 2.79
AFAIK there are no noticeable changes to creating actions, fcurves or inserting keyframes in 2.80.
Some blender API basics
bpy.types.bpy_struct
built-in base class for all classes in bpy.types.
bpy_struct.keyframe_insert(...)
Insert a keyframe on the property given, adding fcurves and animation
data when necessary. Strongly recommend you visit and checkout the examples given
hence the keyframe_insert
method will belong to all objects in bpy
whether they are animatable or not. Was there a slogan? Blender everything** is animatable
obj = bpy.context.object
# set the keyframe at frame 1
obj.location = 3.0, 4.0, 10.0
obj.keyframe_insert(data_path="location", frame=1)
which will, if needed create the animation data, create the action, create the fcurves, and then insert keyframes into action fcurves for the given data path and array index.
Lets do this with an action
>>> action = D.actions.new("dummy")
>>> action.location = 1, 2, 3
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
AttributeError: 'Action' object has no attribute 'location'
oh an error, wait... could this be the reason for action.keyframe_insert("location")
throwing
TypeError: bpy_struct.keyframe_insert() property "location" not found
I believe so. Has nothing to do with object selection. It's OOP 101 the object is in this case a new action named "dummy", referenced by variable action
.
Ok then what about a property that does belong to an action like frame_range
let's animate that so at every frame the frame range of the action changes..
>>> D.actions['dummy'].keyframe_insert("frame_range")
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
TypeError: bpy_struct.keyframe_insert() property "frame_range" not animatable
but it says the property is animatable
>>> D.actions['dummy'].bl_rna.properties['frame_range'].is_animatable
True
in hindsight, perhaps this property is read only since it is basically the minimum / maximum of keyframe frames over all fcurves, and hence can't be animated.
>>> D.actions['dummy'].bl_rna.properties['frame_range'].is_readonly
True
Believe this also answers why option 2 in your answer
"doesn't work". Being able to animate fcurve keyframe coordinates would mean the graphs changing when the frame changes.... possibly (probably) not plausible.
The method to
make a simple scale action
emulates keyframe_insert("scale")
to some extent without "being tied to any object" Could be edited to create fcurves with any values for datapath and array index.
Related
Fast keyframe insertion from data
Quite probably a duplicate question.
How do I add keyframes to a newly created action with no associated objects?
**Almost everything