Keyframe a driver / Triggering scripted expression with a keyframe I want to keyframe a driver. I have a driver on the X rotation that is driven based on the Y position. So it rotates along the X when it moves along the Y. However, i don't need it to rotate all the time when it moves along that axis but only at a certain time. So, for example: don't evaluate the driver until you're on frame 32 or beyond. (If frame >= 32 then evaluate driver's expression)

I want to go from this:


To this:



The desirable effect is achieved by baking down the animation and just tweaking the keyframes in the Dope Sheet... but, as you can understand, it removes all the procedural data, which is not desirable.

And, i don't know if it deserves a separate question, how do i calculate a delta with python? If there is a way to keyframe a driver, then i don't want just to grab the current value from the position and use it to calculate rotation; i want it to be like that: (If frame >= 32 then PositionOnFrame32 - PositionOnCurrentFrame). And i think i need it to put in the modulus (absolute value) function so to eliminate negative values.
You can use Python's ternary if-else operator:

function_of(y_location) if frame &gt;= 32 else 0


You can nest these.

If you need to evaluate some object's position at given frame, you have to use PyDriver.

Like batFINGER suggested, binding this to the start and end position of the teeth rack (or to 2 empties) would work well also. That would look like this:

(rot_fce(y_loc) if y_loc &lt; end_loc else rot_fce(end_loc)) if y_loc &gt;= start_loc else 0