Creating a Graph Editor Operator that edits keyframe handles

Hello! I’m trying to create a keyframe operator for the Graph Editor that adjusts keyframe bezier handle lengths.

I’m following the example of keyframe snapping operator, GRAPH_OT_snap, which uses ANIM_fcurve_keyframes_loop to loop through the keyframes. One of its arguments is the KeyframeEditFunc where the callback containing the keyframe editing logic goes. The callbacks only accept KeyframeEditData and BezTriple as arguments, though.

If I’m to add the keyframe editing code in the callbacks of this function, how can I reference my operator properties without passing them as arguments?

Thank you!

I’m not sure if this is a good way to do it, but I was able to get it working by not using the same callbacks as GRAPH_OT_snap so I could send my operator properties as arguments.

D13702

I only looked at this briefly, and I’m not familiar with the area, but it looks like KeyframeEditData has a generic data pointer that can point whatever struct you want. That could be your operator directly, or a struct you derived from its properties.

Generally I’d suggest retrieving the arguments from your operator very early on in its execution, mostly to avoid the computational and reader overhead of accessing properties from the operator instead of a small struct directly.

1 Like