# Delete unused Empty

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':

for ob in scene.objects:
if ob.type == 'EMPTY' and ob not in obs: