I'm trying to delete shape key drivers using Python, to clean up scenes. However, I cannot delete some drivers for previously deleted shapekeys:

driver_data_path = bpy.context.object.data.shape_keys.animation_data.drivers[0].data_path

brings up this error:

Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: bpy_struct.driver_remove(): property "key_blocks["Key 1"].value" not found

What I understand is that the data_path is an rna path, which is changed to key_blocks["..."].value when the shapekey is deleted. But then it cannot be found by driver_remove()...

Is this a bug, or is there another way to delete drivers?

  • $\begingroup$ As far as I am aware, when the item with the driver is deleted then the driver will also be removed. $\endgroup$ – Ray Mairlot Aug 1 '14 at 11:57
  • $\begingroup$ I thought so too, but it appears not to be the case, at least with shapekeys. $\endgroup$ – Pisurquatre Aug 1 '14 at 12:37
  • 1
    $\begingroup$ Seems to be a bug. bpy_struct.driver_remove should not rely on the existence of data_path or the removal of a key_block should also delete related drivers. The data_path attribute of the driver is not read-only by the way. $\endgroup$ – pink vertex Aug 1 '14 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.