4
$\begingroup$

I'm trying to make a driver which gets a property value not in current frame, but frame+2 for example. How I can do that?

$\endgroup$

2 Answers 2

4
$\begingroup$

You can evaluate fcurves for a property from python. Let's say you animated object Cube's location and want to get the Z value at frame 15:

# little utility function for searching fcurves
def find_fcurve(id_data, path, index=0):
    anim_data = id_data.animation_data
    for fcurve in anim_data.action.fcurves:
        if fcurve.data_path == path and fcurve.array_index == index:
            return fcurve

# index=2 for the Z curve. Just omit for single value properties.
fcurve = find_fcurve(bpy.data.objects["Cube"], "location", 2)

# Get the value at frame 15
print(fcurve.evaluate(15))

Note that evaluating fcurves may not be accurate in all circumstances, e.g. when you have additional constraints, physics simulation, etc. In that case the only real option may be to actually move to that frame, store the value and go back to the original frame.

$\endgroup$
0
$\begingroup$

Correction to my original answer: frame+2 in the expression field should give you exactly that.

enter image description here

$\endgroup$
2
  • 3
    $\begingroup$ Unless i misunderstood the question, this is not the desired result. It just returns the frame number + 2, not the value of some property at that frame. $\endgroup$
    – user436
    Commented Oct 8, 2013 at 17:19
  • 1
    $\begingroup$ You are right, I misread the question. My bad! $\endgroup$
    – tobkum
    Commented Oct 8, 2013 at 17:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .