From c5262274eb116cfcb6e3b15d7ed9d3d3e91cfb26 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 25 Jun 2024 11:59:18 +0500 Subject: [PATCH] bim.unlink_style - fix issue saving project after unlinking --- .../blenderbim/bim/module/style/operator.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/module/style/operator.py b/src/blenderbim/blenderbim/bim/module/style/operator.py index 08eec96e90..4cff0e54e3 100644 --- a/src/blenderbim/blenderbim/bim/module/style/operator.py +++ b/src/blenderbim/blenderbim/bim/module/style/operator.py @@ -137,6 +137,24 @@ class UnlinkStyle(bpy.types.Operator, tool.Ifc.Operator): core.remove_style(tool.Ifc, tool.Style, style) else: tool.Ifc.unlink(element=style) + + # Ensure there won't be any style sync on project save: + # bim.update_representation would create new IfcSurfaceStyle + # for unlinked blender material. + updated_meshes = set() + for obj in bpy.data.objects: + mesh = obj.data + if not isinstance(mesh, bpy.types.Mesh): + continue + if not mesh.BIMMeshProperties.ifc_definition_id: + continue + if mesh in updated_meshes: + continue + if not mesh.materials.get(material.name): + continue + tool.Geometry.record_object_materials(obj) + updated_meshes.add(mesh) + return {"FINISHED"}