If I want to add a keyframe in the graph editor, I know I can do this:


And I suppose that if I change the 'ALL' to 'SEL', it will only apply to the selected channel, but if I want a script that changes multiple channels in different ways, how can I select them with python?


See this answer and these paragraphs #1, #2, #3, #4 in the docs for api methods/functions to create/manipulate channels.

You might define your own function:

def get_channel(action, data_path, index=0):
    for fcurve in action.fcurves:
        if fcurve.data_path == data_path and fcurve.array_index == index:
            return fcurve
    #nothing found
    return None

action = bpy.data.actions['CubeAction']
data_path = "location"
index = 2

fcurve = get_channel(action, data_path, index)

In this answer some options are given to find out the data_path of a channel.

To select an fcurve in the UI you simply set its select property to True.

| improve this answer | |

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.