Direct FCurve Editing

I’m trying to find a way to directly edit fcurves. For example I can read an fcurve at any frame with:

D.actions[‘Action’].fcurves[0].evaluate(frame)

But how can I insert a keyframe at a specific frame and with a specific value? Like:

D.actions[‘Action’].fcurves[0].key(frame, value)

thanks and have a great weekend

Daniel Salazar
patazstudio.com

You can add keyframe points:

bpy.context.object.animation_data.action.fcurves[0].keyframe_points.add()

Then set their co attribute.

Or set the property value, then use the RNA method keyframe_insert().

Thak you CoDEmanX, that got me to discover the insert() function which is exactly what I needed

http://www.blender.org/api/blender_python_api_2_74_release/bpy.types.FCurveKeyframePoints.html?highlight=keyframe_points