Python API - retrieve interpolation betwwen 2 keyframes ( not only integers )

Hello,

Is there a way, using python API, to retrieve any value of an Fcurve, for a give frame ? But not only integer frame :
For exemple, I have a keyframe at frame 5 and another and frame 6, and I want to retrieve value for frame 5.2

Thanks for your answer :slight_smile:

Regards,

Hi



# some ways to find an action

action = bpy.data.actions['Action']
action = bpy.data.actions.get('Action')  # get returns None if there is no action named Action

action = obj.animation_data.get('Action')

#fcurve collection
fcurves = action.fcurves

#first fcurve in collection
fcurve = action.fcurves[0]

fcurve.data_path # what is being animated
fcurve.array_index # 0,1,2 for x,y,z r,g,b etc

frame = 5.2
fcurve.evaluate(frame)  # the value of fcurve at frame 5.2

yep, FCurve.evaluate(…)

if you don’t use FCurves, you can also set a frame with subframe and read the object matrices for instance:

bpy.context.scene.frame_set(10, 0.5) # Frame 10.5

Hello,

Thanks for your answers !