From 4c057c95bf55d9ed787e9ba5e2c00ed43e003aee Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Tue, 6 Oct 2020 19:08:48 +0200 Subject: [PATCH] Arch: import ifc, colors in IFC4 print warning not implemented --- src/Mod/Arch/importIFCHelper.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Mod/Arch/importIFCHelper.py b/src/Mod/Arch/importIFCHelper.py index bf99b334ef9a..99b5e984355e 100644 --- a/src/Mod/Arch/importIFCHelper.py +++ b/src/Mod/Arch/importIFCHelper.py @@ -439,24 +439,23 @@ def getColorFromStyledItem(styled_item): # In current IFC release (IFC2x3) only one presentation style # assignment shall be assigned. - # TODO: check IFC4 - - if len(styled_item.Styles) != 1: - # Normally, only one element in `Styles` should be available. + # In IFC4 `IfcPresentationStyleAssignment` is deprecated + # In IFC4 multiple styles are assigned to style in 'IfcStyleItem' instead + + # print(ifcfile[p]) + # print(styled_item) + # print(styled_item.Styles) + if len(styled_item.Styles) == 1: + # IN IFC2x3, only one element in `Styles` should be available. _wrn("More than one 'Style' in 'IfcStyleItem', do nothing.") - - # These two cases do nothing so we just comment them out. - # if len(styled_item.Styles) == 0: - # # ca 100x in 210_King_Merged.ifc - # # Empty styles, #4952778=IfcStyledItem(#4952779,(),$) - # # this is an error in the IFC file in my opinion - # # print(ifcfile[p]) - # # print(styled_item) - # # print(styled_item.Styles) - # pass - # else: - # # Never seen an IFC with more than one element in `Styles` - # pass + # ca 100x in 210_King_Merged.ifc + # Empty styles, #4952778=IfcStyledItem(#4952779,(),$) + # this is an error in the IFC file in my opinion + elif len(styled_item.Styles) > 1: + # never seen an ifc with more than one Styles in IfcStyledItem + # the above seams to only apply for IFC2x3, IFC4 can have them + # see https://forum.freecadweb.org/viewtopic.php?f=39&t=33560&p=437056#p437056 + _wrn("More than one 'Style' in 'IfcStyleItem', not implemented, do nothing.") else: # Get the `IfcPresentationStyleAssignment`, there should only be one, if styled_item.Styles[0].is_a('IfcPresentationStyleAssignment'):