# Python. How to find a point on the timeline where Fcurve reaches a certain value without changing current subframe?

Is there any way to find out via Python at which point of the Timeline (at which subframe) fcurve reaches a certain value, without actually changing the current subframe? I have found out that it was possible to get certain keyframe_points coordinates on the timeline, but is there any way to analyze the whole fcurve somehow?

Using FCurve.evaluate(frame) and numpy

In this related answer have found the minimum of an fcurve based on 0.01 subframe increments, instead here will find the first point where the fcurve is greater than a given value.

Test script, loops over all actions and prints the frame (and value) where it first exceeds value.

import bpy
import numpy as np

value = 10

frames = np.arange(1, 250, 0.01)

for action in bpy.data.actions:
print(f"{action.name}")

for fc in action.fcurves:
print(f"{fc.data_path}[{fc.array_index}]")
points = np.vectorize(fc.evaluate)(frames)

hit = np.where(points > value)[0]
if hit.size:
f = hit[0]

print(f"{frames[f]} : value {points[f]}")

• Thank you! FCurve.evaluate(frame) is exactly what I was looking for! Aug 8 '20 at 19:26