From 74a1f21b67c17455fa757753ad54d737f4789288 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Tue, 6 Oct 2020 17:16:42 +0200 Subject: [PATCH] Arch: import ifc, fix import break if colors dictionary contains None values --- src/Mod/Arch/importIFC.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index 440ab84104..1f124a48d6 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -1248,10 +1248,13 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): # Materials if preferences['DEBUG'] and materials: print("Creating materials...",end="") + # print("\n") + # print("colors:",colors) # print("mattable:",mattable) # print("materials:",materials) fcmats = {} for material in materials: + # print(material.id()) # get and set material name name = "Material" if material.Name: @@ -1259,13 +1262,16 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): if six.PY2: name = name.encode("utf8") # get material color + # the "DiffuseColor" of a material should never be 'None' + # values in colors are None if something went wrong + # thus the "DiffuseColor" will only be set if the color is not None mdict = {} - if material.id() in colors: + if material.id() in colorscolors and colors[material.id()] is not None: mdict["DiffuseColor"] = str(colors[material.id()]) else: for o,m in mattable.items(): if m == material.id(): - if o in colors: + if o in colors and colors[o] is not None: mdict["DiffuseColor"] = str(colors[o]) # merge materials with same name and color if setting in prefs is True add_material = True