From aa33cdc1863f641b5bd309929804e426da79254a Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Wed, 10 Nov 2021 15:59:30 +0100 Subject: [PATCH] Arch: export IFC, make compatible with ifcopenshell 0.7 --- src/Mod/Arch/exportIFC.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Mod/Arch/exportIFC.py b/src/Mod/Arch/exportIFC.py index 6c4fc01e52..50dc7d23a5 100644 --- a/src/Mod/Arch/exportIFC.py +++ b/src/Mod/Arch/exportIFC.py @@ -162,9 +162,22 @@ def getPreferences(): 'EXPORT_MODEL': ['arch', 'struct', 'hybrid'][p.GetInt("ifcExportModel", 0)] } + # get ifcopenshell version + ifcos_version = 0.0 + if hasattr(ifcopenshell, "version"): + if ifcopenshell.version.startswith("0"): + ifcos_version = float(ifcopenshell.version[:3]) # < 0.6 + elif ifcopenshell.version.startswith("v"): + ifcos_version = float(ifcopenshell.version[1:4]) # 0.7 + else: + print("Could not retrieve IfcOpenShell version. Version is set to {}".format(ifcos_version)) + else: + print("Could not retrieve IfcOpenShell version. Version is set to {}".format(ifcos_version)) + + # set schema if hasattr(ifcopenshell, "schema_identifier"): schema = ifcopenshell.schema_identifier - elif hasattr(ifcopenshell, "version") and (float(ifcopenshell.version[:3]) >= 0.6): + elif ifcos_version >= 0.6: # v0.6 onwards allows to set our own schema schema = ["IFC4", "IFC2X3"][p.GetInt("IfcVersion", 0)] else: