How to detect and remove "orphaned" drivers

Hi again :slight_smile:

One thing I’ve noticed about copying and pasting drivers in Blender is that the entries in the graph editor are just not synched with the either the operations done manually through the GUI or when passed through a script. Like, if you delete a shape key that has a driver on it, the driver can still be seen in the graph editor, giving out an error that it is not being owned by anything.

Is there a way to detect “orphaned” drivers and delete them through Python?

Thanx and cheers;

AJ

I think I would just have a function that clears the key_block of its drivers before I delete it, to be on the safe side. But that’s just my opinion.

Yes this function bpy.data.driver_remove() with a loop

but the Orphan Cleanup add-on don’t be easily modified to make this function.
Desoled!
Bye

LINK: https://github.com/meta-androcto/blenderpython/blob/master/scripts/addons_extern/orphan_cleanup.py