Skip to content

Commit

Permalink
fix: ensure clean_utils also handles mirror and array empty objects i…
Browse files Browse the repository at this point in the history
…n utils collection
  • Loading branch information
tristan-hm committed Jun 5, 2022
1 parent 3f4e47b commit 43c0c82
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions utils/clean_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,33 @@ def remove_utils(self):
active_util_object_names = set()
all_scene_objects = [obj for obj in bpy.data.objects if obj.type == 'MESH']
all_util_objects = get_all_util_objects()
util_mods = ['BOOLEAN', 'ARRAY', 'MIRROR']

remove_mods = []

for obj in all_scene_objects:
mods = list(obj.modifiers)
for mod in mods:
if mod.type != 'BOOLEAN':
continue
if mod.object:
active_util_object_names.add(mod.object.name)
if mod.type not in util_mods:
continue
obj.modifiers.remove(mod)

if mod.type == 'BOOLEAN':
if mod.object:
active_util_object_names.add(mod.object.name)
else:
remove_mods.append((obj, mod))

if mod.type == 'ARRAY':
if mod.offset_object:
active_util_object_names.add(mod.offset_object.name)

if mod.type == 'MIRROR':
if mod.mirror_object:
active_util_object_names.add(mod.mirror_object.name)

for obj, mod in remove_mods:
obj.modifiers.remove(mod)

for obj in all_util_objects:
if obj.name not in active_util_object_names:
bpy.data.objects.remove(obj, do_unlink=True)
Expand Down

0 comments on commit 43c0c82

Please sign in to comment.