From 81471d80cd977d03327d411ac01ea8f38b40df43 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 30 Mar 2023 17:10:27 +0500 Subject: [PATCH] Fixed bug causing errors in IFC4X3 projects It was causing an error below on opening BIM Tool and probably in some other places. ``` Traceback (most recent call last): File "C:\software\Steam\steamapps\common\Blender\3.5\scripts\startup\bl_ui\space_view3d.py", line 35, in draw self.draw_tool_settings(context) File "C:\software\Steam\steamapps\common\Blender\3.5\scripts\startup\bl_ui\space_view3d.py", line 48, in draw_tool_settings tool = ToolSelectPanelHelper.draw_active_tool_header( File "C:\software\Steam\steamapps\common\Blender\3.5\scripts\startup\bl_ui\space_toolsystem_common.py", line 809, in draw_active_tool_header draw_settings(context, layout, tool) File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\workspace.py", line 67, in draw_settings BimToolUI.draw(context, layout) File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\workspace.py", line 89, in draw AuthoringData.load() File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\data.py", line 52, in load cls.load_ifc_classes() File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\data.py", line 109, in load_ifc_classes cls.data["ifc_classes"] = cls.ifc_classes() File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\data.py", line 196, in ifc_classes + tool.Ifc.get().by_type("IfcDoorStyle") File "\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\file.py", line 364, in by_type return [entity_instance(e, self) for e in self.wrapped_data.by_type(type)] File "\Blender\3.5\scripts\addons\blenderbim\libs\site\packages\ifcopenshell\ifcopenshell_wrapper.py", line 4499, in by_type return _ifcopenshell_wrapper.file_by_type(self, *args) RuntimeError: Entity with name 'IfcDoorStyle' not found in schema 'IFC4X3' Traceback (most recent call last): File "C:\software\Steam\steamapps\common\Blender\3.5\scripts\startup\bl_ui\space_view3d.py", line 35, in draw self.draw_tool_settings(context) File "C:\software\Steam\steamapps\common\Blender\3.5\scripts\startup\bl_ui\space_view3d.py", line 48, in draw_tool_settings tool = ToolSelectPanelHelper.draw_active_tool_header( File "C:\software\Steam\steamapps\common\Blender\3.5\scripts\startup\bl_ui\space_toolsystem_common.py", line 809, in draw_active_tool_header draw_settings(context, layout, tool) File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\workspace.py", line 67, in draw_settings BimToolUI.draw(context, layout) File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\workspace.py", line 92, in draw cls.draw_header_interface() File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\workspace.py", line 351, in draw_header_interface cls.draw_type_selection_interface() File "\Blender\3.5\scripts\addons\blenderbim\bim\module\model\workspace.py", line 367, in draw_type_selection_interface if AuthoringData.data["ifc_classes"]: KeyError: 'ifc_classes' ``` --- src/blenderbim/blenderbim/bim/module/model/data.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/data.py b/src/blenderbim/blenderbim/bim/module/model/data.py index e9e7747649..336cd28b02 100644 --- a/src/blenderbim/blenderbim/bim/module/model/data.py +++ b/src/blenderbim/blenderbim/bim/module/model/data.py @@ -191,12 +191,13 @@ class AuthoringData: def ifc_classes(cls): results = [] classes = { - e.is_a() - for e in tool.Ifc.get().by_type("IfcElementType") - + tool.Ifc.get().by_type("IfcDoorStyle") - + tool.Ifc.get().by_type("IfcWindowStyle") - + tool.Ifc.get().by_type("IfcSpaceType") + e.is_a() for e in (tool.Ifc.get().by_type("IfcElementType") + tool.Ifc.get().by_type("IfcSpaceType")) } + + if tool.Ifc.get_schema() in ("IFC2X3", "IFC4"): + classes.update( + {e.is_a() for e in (tool.Ifc.get().by_type("IfcDoorStyle") + tool.Ifc.get().by_type("IfcWindowStyle"))} + ) results.extend([(c, c, "") for c in sorted(classes)]) return results