From 6cd91619868c06d00275d4ff0dd368aeadd2217f Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 19 Jun 2023 19:01:43 +0500 Subject: [PATCH] Fixed import error with filtering out IfcGrid's spatial element #3283 Fixed error that was occuring if you try to import .ifc file where spatial element contains only grid and will use advanced mode, filter mode = "IFC Class" and check "Filter Spatial Elements". Error occured because spatial element was filtered out but then when ifc grid was created and importer to find a spatial element based collection for the grid it couldn't find it. Traceback: Error: Python: Traceback (most recent call last): File "\blenderbim\bim\module\project\operator.py", line 595, in execute ifc_importer.execute() File "\blenderbim\bim\import_ifc.py", line 260, in execute self.place_objects_in_collections() File "\blenderbim\bim\import_ifc.py", line 1494, in place_objects_in_collections self.place_object_in_collection(self.file.by_id(ifc_definition_id), obj) File "\blenderbim\bim\import_ifc.py", line 1498, in place_object_in_collection self.place_object_in_decomposition_collection(element, obj) File "\blenderbim\bim\import_ifc.py", line 1517, in place_object_in_decomposition_collection return self.place_object_in_spatial_decomposition_collection(element, obj) File "\blenderbim\bim\import_ifc.py", line 1545, in place_object_in_spatial_decomposition_collection self.collections[container.GlobalId].children.link(grid_collection) KeyError: '33AiKftFj2aAf2MqQr5Gs7' --- src/blenderbim/blenderbim/bim/import_ifc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/bim/import_ifc.py b/src/blenderbim/blenderbim/bim/import_ifc.py index b91d0e2d51..4d05b94206 100644 --- a/src/blenderbim/blenderbim/bim/import_ifc.py +++ b/src/blenderbim/blenderbim/bim/import_ifc.py @@ -347,7 +347,8 @@ class IfcImporter: self.element_types = set(self.file.by_type("IfcTypeProduct")) if self.ifc_import_settings.has_filter and self.ifc_import_settings.should_filter_spatial_elements: - self.spatial_elements = self.get_spatial_elements_filtered_by_elements(self.elements) + filtered_elements = self.elements | set(self.file.by_type("IfcGrid")) + self.spatial_elements = self.get_spatial_elements_filtered_by_elements(filtered_elements) else: if self.file.schema == "IFC2X3": self.spatial_elements = set(self.file.by_type("IfcSpatialStructureElement"))