deleting channels in the Graph Editor?

I was able to insert a Location keyframe in the graph editor by code.
Now I want to delete the y and z channels of the Location and keep the x by code.
How can I do that.
I’m in the Graph Editor context but howering the mouse on the y and z channel names I get no API hint.

fcurves = ob.animation_data.action.fcurves
fcu = fcurves[1] # for instance, you would need to loop over all and check data_path and array_index in real code
fcurves.remove(fcu)

But do you keyframe Y and Z in the first place?
keyframe_insert() takes an index parameter, -1 means all channels (default), 0 only X.

Or create just one F-Curve for index 0 if you use low-level RNA methods:
http://www.blender.org/documentation/blender_python_api_2_69_10/info_quickstart.html#animation

thank you

I can’t find such info in the API reference. http://www.blender.org/documentation/blender_python_api_2_69_10/bpy.ops.anim.html
I don’t know the difference between keyframe_insert() and keyframe_insert_menu() so i tried your suggestion on both. Still x , y as well as z are insterted.


bpy.ops.anim.keyframe_insert(0, type='Scaling')
bpy.ops.anim.keyframe_insert_menu(0, type='Scaling')

You can get to every f-curve of an object by using this:

myFcurves = myObject.animation_data.action.fcurves

Then you can go in and delete an f-curve, you have to know the index though. For example, if you only have location keyframes, index 0 is x, 1 is y and 2 is z

myFcurves[index]

You can check the type of f-curve with:

myFcurves[index].data_path

and

myFcurves[index].array_index

Back to removing the f-curve, simply use:

myFcurves.remove(myFcurves[index])

thanks a lot

http://www.blender.org/documentation/blender_python_api_2_69_10/bpy.types.bpy_struct.html?highlight=keyframe_insert#bpy.types.bpy_struct.keyframe_insert

keyframe_insert_menu() is an operator, you shoudn’t use operators for keyframe insertion in python scripts.

keyframe_insert() is also an operator, but I didn’t mean the operator with this name, but the RNA method keyframe_insert() (see above link)