# Set Active FCurve in Graph Editor through python

I'm trying to set an FCurve in the Graph Editor to "Active" through python.

In the API FCurves don't actually have an "Active" property, but manually click-selecting a channel or keyframe on an FCurve will bring up this in the Graph's UI:

You can see that the curve gets a very bright highlight and the UI panel on the right now shows that the curve is Active.

FCurve's do have a "select" property that when set to True through script will select the curve. But just setting the select property to True doesn't produce the same result. It only selects the curve but doesn't consider it active, like this:

Even though the curve/channel is selected you can see the curve's highlight is not nearly as bold now, and the UI panel on the right shows no active curve at all.

So I started digging through the source code and found that there's an FCURVE_ACTIVE flag that does in fact get set, but I can't figure out how to do anything through script that would trigger anything that might set that flag.

Here's a link to an ANIM_set_active_channel function in anim_channels_edit.c from the source code:

ANIM_set_active_channel

You can see down on line 111 the FCURVE_ACTIVE flag is set.

This function is called in a number of different places:

• action_select.c
• nla_channels.c
• nla_select.c
• graph_select.c
• ED_anim_api.h

Does anyone know how this works? What is Blender doing once it reads the flag to brightly highlight the curve and make it show up in the right UI panel? Can this be reproduced through script without having to manually click-select on either a keyframe or an action channel?

Thanks for any ideas.

• I just bumped into a similar issue. Were you able to identify and fix the problem? Jun 5 at 20:14

Hi I know this is too late, but I've found a way to set active the f-curve

import bpy

data = bpy.data
context = bpy.context
obj = context.object

previous_area_type = context.area.type

context.area.type = 'GRAPH_EDITOR'

print(context.editable_fcurves[0].select)

context.editable_fcurves[0].select = True

context.area.type = previous_area_type

• From the question "FCurve's do have a "select" property that when set to True through script will select the curve. But just setting the select property to True doesn't produce the same result. It only selects the curve but doesn't consider it active, like this:" Aug 28 at 16:28