in my scene I had an object with a mirror-modifier attached. I made several copies of it. Now I discovered that it also copied the empty I used as the mirror object. I want all new objects using the same empty as mirror object. So I changed (most of) them to point to the original emtpy. Now I want to delete the unused copies of the empty. Is there a way to figure out which empties I can delete and which I have to keep because some are still used for mirroring.
If you want to delete all empties in the current scene, which are not used as mirror object by a mirror modifier, you can use the following script:
import bpy scene = bpy.context.scene obs = set() for ob in scene.objects: for mod in ob.modifiers: if mod.type == 'MIRROR': obs.add(mod.mirror_object) for ob in scene.objects: if ob.type == 'EMPTY' and ob not in obs: #scene.objects.unlink(ob) # version < 2.8 bpy.data.objects.remove(ob) # do unlink is default
Note that it will remove empties even if they are used by other modifiers for instance. There is no direct way to figure out all dependencies to tell what users a certain object has.