1
$\begingroup$

I'm trying to delete an F-Curve. I'm aware that an F-Curve can be deleted when iterating through bpy.data.actions and using the ActionFCurves.remove method. In a case such as this, however, I'm not sure how to get to the F-Curve's ActionFCurves.

fcurves = bpy.context.visible_fcurves[:]
for fcurve in fcurves:
    if fcurve.mute:
        #deletion code goes here

Can anyone please advise on how to delete an F-Curve without having to loop through the bpy.data.actions? Thank you!

$\endgroup$
0

1 Answer 1

3
$\begingroup$

I think that you can get the action from the fcurve with the id_data attribute (since actions are an ID type):

for fcurve in bpy.context.visible_fcurves :
    if fcurve.mute:
        action = fcurve.id_data
        action.fcurves.remove(fcurve)

i changed a bit the beginnig of your code, you can also go for a one liner :

for fcurve in [fcurve for fcurve in bpy.context.fcurves if fcurve.mute] :
    action = fcurve.id_data
    action.fcurves.remove(fcurve)
$\endgroup$
1
  • 1
    $\begingroup$ This helped me SO much, thank you!!!! $\endgroup$ Commented Feb 4, 2022 at 18:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .