From 0e7a70566437ed30561b05155db85b9e1f7b3484 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Thu, 7 Nov 2019 08:04:09 +0100 Subject: [PATCH] Arch: import IFC, fix if imported in non Gui mode --- src/Mod/Arch/importIFC.py | 47 ++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index bd87ab32af..bdde49ee34 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -1149,30 +1149,31 @@ def insert(filename,docname,skip=[],only=[],root=None,preferences=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 whereas in FreeCAD the shape color will be - # overwritten by the material color (if there is a material with a color). - # In such a case FreeCAD shows a 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 FreeCAD.GuiUp: + # the reason behind ... + # there are files around in which the material color is different from the shape color + # all viewers use the shape color whereas in FreeCAD the shape color will be + # overwritten by the material color (if there is a material with a color). + # In such a case FreeCAD shows a 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) + 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 preferences['DEBUG'] and materials: print("done")