Is it possible with a Python script to select the curve of an object with its name ("location x", "location y", "rotation z", ....) instead of its number.

For example, I tweak the Z location of an object with

bpy.data.objects["Pixel X0006 Y0006"].animation_data.action.fcurves[2].keyframe_points[0].interpolation = 'LINEAR'

and I would like to select it by a name rather than with fcurves[2]. It would be more convenient for my scripts.

Is it possible to do that ?

  • $\begingroup$ Try printing the name of the curve. Try to [find] the curve by name. I will check to see where this function is. You may be faster than I am. $\endgroup$ – atomicbezierslinger Mar 12 '20 at 16:48

Yes its possible.

This is an excerpt from an older, non latest version of Blender script. The relevant part may still work. Note the find function. You can see the name of the curve in the FCurves Editor Panel. Note curves may have an index X in the set [0,1,2].

object_bq = bpy.data.objects[name]
test = object_bq.animation_data.action if (None != object_bq.animation_data and (None != object_bq.animation_data.action)) else None;
if (test):
    fc = object_bq.animation_data.action.fcurves.find("Some Curve Name Visible in the FCurves Editor Panel");




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.