From 80af847f99e79c315922bd96af45461c443682de Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 13 Sep 2024 14:15:20 +0500 Subject: [PATCH] purge unused material to try to purge materials recursively #3914 As on first iteration it may remove only unused material sets and on the next iteration it will be able to remove IfcMaterials that were not used anywhere else besides those material sets. --- src/bonsai/bonsai/tool/material.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bonsai/bonsai/tool/material.py b/src/bonsai/bonsai/tool/material.py index 7ddfba250e..e7814cd31b 100644 --- a/src/bonsai/bonsai/tool/material.py +++ b/src/bonsai/bonsai/tool/material.py @@ -413,4 +413,9 @@ class Material(bonsai.core.tool.Material): continue ifcopenshell.api.material.remove_material(ifc_file, material) i += 1 + + if i == 0: + return 0 + + i += cls.purge_unused_materials() return i