From f9da862dcc1f58f28a3370b696a38996fb70686d Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Tue, 26 Oct 2021 22:13:09 +0200 Subject: [PATCH] Arch: import IFC, fix import if replace project and only one building or one storey --- src/Mod/Arch/importIFC.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index 7b240cc09f..0250422507 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -1328,6 +1328,21 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): # print(" ", m, ": ", colors[m]) if preferences['DEBUG'] and materials: print("done") + # Grouping everything if required + + # has to be before the Layer + # if REPLACE_PROJECT and only one storey and one building both are omitted + # the pure objects do not belong to any container, they will be added here + # if after Layer they are linked by Layer and will not be added here + if preferences['REPLACE_PROJECT'] and filename: + rootgroup = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup","Group") + rootgroup.Label = os.path.basename(filename) + print(objects) + for key,obj in objects.items(): + # only add top-level objects + if not obj.InList: + rootgroup.addObject(obj) + # Layers if preferences['DEBUG'] and layers: print("Creating layers...", end="") @@ -1357,15 +1372,6 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): if l: setattr(p[0],p[1],l) - # Grouping everything if required - if preferences['REPLACE_PROJECT'] and filename: - rootgroup = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup","Group") - rootgroup.Label = os.path.basename(filename) - for key,obj in objects.items(): - # only add top-level objects - if not obj.InList: - rootgroup.addObject(obj) - # Save colordict in non-GUI mode if colordict and not FreeCAD.GuiUp: import json