Previous Thread  Next Thread

chat icon Can't run bpy.ops.anim.channels_delete() in my script

john.cfng

Posted: Fri Oct 12, 2012 5:43 am
Joined: 30 Sep 2012
Posts: 3
Hi all,

I tried to use script to remove particular animation channels of an object.
here are the scripts after setting the .select of the channels to True of those channels
area_type_original = bpy.context.area.type
bpy.context.area.type = 'GRAPH_EDITOR'
bpy.ops.anim.channels_delete()
bpy.context.area.type = area_type_original
however, channels are not deleted

Blender returns False If I replace the line bpy.ops.anim.channels_delete() to bpy.ops.anim.channels_delete.poll()

I tried changing the area type to 'DOPESHEET_EDITOR', but this also failed

Would any one please help me with this? what should I do to delete specific animation channels?

System information: Blender 2.63a, Win7 64bit English

Thank you very much.
JNg
Reply with quote


CoDEmanX

Posted: Fri Oct 12, 2012 7:40 am
Joined: 05 Apr 2009
Posts: 680
I would rather use low-level functions like this:

Code:
action = bpy.context.object.animation_data.action

for f in action.fcurves:

    # find X Location fcurve
    if f.data_path == 'location' and f.array_index == 1:
        a.fcurves.remove(f)
        break

_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


CoDEmanX

Posted: Fri Oct 12, 2012 7:41 am
Joined: 05 Apr 2009
Posts: 680
sorry, it's Y Location (array_index 0 = X, 1 = Y, 2 = Z / if it's a quaternion then 0-3 = wxyz)
_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


john.cfng

Posted: Fri Oct 12, 2012 8:44 am
Joined: 30 Sep 2012
Posts: 3
Hi CoDEmanX,

Thank you very much. It works great! Problem solved.
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group