I want to delete all drivers on object in Blender 2.8. I am quite new to the scripting and the only code I have found is this:

import bpy

ob = bpy.context.active_object
drivers_data = ob.animation_data.drivers

for dr in drivers_data:  
    ob.driver_remove(dr.data_path, -1)

But it doesn't work. I think there are some little changes needed for Blender 2.8 and later.

Thank you for any help.


After some tries I found out, this code actually works, but only on transform drivers, etc. I need this script to work on shape keys drivers. Basically, I need to delete all drivers (channels) like I would in the drivers editor.

In the end I figured this out! Here is the functioning code:

import bpy

fcurves = bpy.data.shape_keys["Key"].animation_data.drivers

for fc in fcurves:
  • $\begingroup$ That code worked for me, why didn't it work for you? This is a request for specificity in your question. What do you mean by 'it doesn't work.' $\endgroup$
    – Ron Jensen
    Commented Sep 7, 2020 at 21:48
  • $\begingroup$ @Ron Jensen So, it gives me this error in console: AttributeError: 'NoneType' object has no attribute 'drivers'. But my object has drivers, so I don't understand. $\endgroup$
    – Araras
    Commented Sep 7, 2020 at 22:00
  • $\begingroup$ I get that error if my object doesn't have drivers. Make sure you object is the active object. What properties are the drivers on? $\endgroup$
    – Ron Jensen
    Commented Sep 7, 2020 at 23:19
  • $\begingroup$ @Ron Jensen I was wrong as it works on simple transform drivers, but what I actually need is to delete drivers from shape keys as well. They are also called channels or Fcurves I think, but that's what I am struggling with now. $\endgroup$
    – Araras
    Commented Sep 8, 2020 at 1:13
  • $\begingroup$ Can this solution be used in 2.79? I have looked all over but can't find anything. When I run your solution in Blender 2.79 it says 'NoneType' object has no attribute 'drivers'. Can someone please show how to modify this for Blender 2.79 ?? $\endgroup$
    – Logic1
    Commented Oct 31, 2020 at 21:52

1 Answer 1

import bpy

selected = bpy.context.selected_objects

for o in selected:
    od = o.animation_data.drivers.values()
    for d in od:       

You must log in to answer this question.

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