From 43c0c822f964be175a5b38461bf3a1da8267a6dc Mon Sep 17 00:00:00 2001 From: Tristan Strathearn Date: Sun, 5 Jun 2022 19:45:35 +1000 Subject: [PATCH] fix: ensure clean_utils also handles mirror and array empty objects in utils collection --- utils/clean_utils.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/utils/clean_utils.py b/utils/clean_utils.py index ff5cbe5..c0f48d4 100644 --- a/utils/clean_utils.py +++ b/utils/clean_utils.py @@ -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)