From c6e11c4ac16fad0ec4ef33697e2be0386c3a2592 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Fri, 9 Aug 2019 00:21:38 +0200 Subject: [PATCH] Arch: IFC import, inform user if material color != shape color --- src/Mod/Arch/importIFC.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index f4e12053d3..9a4547a543 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -1240,7 +1240,30 @@ def insert(filename,docname,skip=[],only=[],root=None): if m == material.id(): if o in objects: if hasattr(objects[o],"Material"): + # the reason behind ... + # there are files around in which the material color is different from the shape color + # all viewers use the shape color wheras in FreeCAD the shape color will be + # overwritten by the material coloer (if there is a material with a color) + # in such a case FreeCAD shows different color than all common ifc viewers + # https://forum.freecadweb.org/viewtopic.php?f=39&t=38440 + col = objects[o].ViewObject.ShapeColor[:3] + dig = 5 + ma_color = sh_color = round(col[0], dig), round(col[1], dig), round(col[2], dig) objects[o].Material = mat + if "DiffuseColor" in objects[o].Material.Material: + sting_col_ = objects[o].Material.Material["DiffuseColor"] + col = tuple([float(f) for f in sting_col_.strip("()").split(",")]) + ma_color = round(col[0], dig), round(col[1], dig), round(col[2], dig) + if ma_color != sh_color: + print("\nobject color != material color for object: ", o) + print(" material color is used (most software uses shape color)") + print(" obj: ", o, "label: ", objects[o].Label, " col: ", sh_color) + print(" mat: ", m, "label: ", mat.Label, " col: ", ma_color) + # print(" ", ifcfile[o]) + # print(" ", ifcfile[m]) + # print(" colors:") + # print(" ", o, ": ", colors[o]) + # print(" ", m, ": ", colors[m]) if DEBUG and materials: print("done")