From cc1e6246437e5c48adf49569d7b29ab46ecd4d79 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Fri, 20 Jan 2023 15:52:55 +0100 Subject: [PATCH] Arch: import ifc, workaround for merge materials if material colors have not been found on import --- src/Mod/Arch/importIFC.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index bc08a07b1e..be568755e2 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -1187,15 +1187,26 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): if preferences["MERGE_MATERIALS"]: for added_mat in added_mats: if ( - "Description" in added_mat.Material - and "DiffuseColor" in added_mat.Material - and "DiffuseColor" in mdict # Description has been set thus it is in mdict + "Description" in added_mat.Material # Description has been set thus it is in mdict and added_mat.Material["Description"] == mdict["Description"] - and added_mat.Material["DiffuseColor"] == mdict["DiffuseColor"] ): - matobj = added_mat - add_material = False - break + if ( + ( + "DiffuseColor" in added_mat.Material + and "DiffuseColor" in mdict + and added_mat.Material["DiffuseColor"] == mdict["DiffuseColor"] + ) # color in added mat with the same matname and new mat is the same + or + ( + "DiffuseColor" not in added_mat.Material + and "DiffuseColor" not in mdict + ) # there is no color in added mat with the same matname and new mat + # on modell imported from ArchiCAD color was not found for all IFC material objects, + # thus DiffuseColor was not set for created materials, workaround to merge these too + ): + matobj = added_mat + add_material = False + break # add a new material object if add_material is True: