diff --git a/src/blenderbim/blenderbim/bim/import_ifc.py b/src/blenderbim/blenderbim/bim/import_ifc.py index d7b6bb915b..086827f1d5 100644 --- a/src/blenderbim/blenderbim/bim/import_ifc.py +++ b/src/blenderbim/blenderbim/bim/import_ifc.py @@ -431,7 +431,7 @@ class IfcImporter: self.annotations = set([a for a in self.file.by_type("IfcAnnotation")]) self.annotations -= drawing_annotations - self.elements = [e for e in self.elements if not e.is_a("IfcFeatureElement")] + self.elements = [e for e in self.elements if not e.is_a("IfcFeatureElement") or e.is_a("IfcSurfaceFeature")] if self.ifc_import_settings.is_coordinating: self.elements = [e for e in self.elements if e.Representation] @@ -863,7 +863,6 @@ class IfcImporter: else: self.create_generic_elements(self.spatial_elements, unselectable=False) - def create_elements(self) -> None: self.create_generic_elements(self.elements) tmp = self.context_settings @@ -1639,6 +1638,8 @@ class IfcImporter: rel_aggregates.add(nested_by[0]) elif nests := getattr(element, "Nests", []): rel_aggregates.add(nests[0]) + elif element.is_a("IfcSurfaceFeature") and self.file.schema == "IFC4X3": + rel_aggregates.add(element.AdheresToElement[0]) else: rel_aggregates = [ r @@ -1654,6 +1655,8 @@ class IfcImporter: ) and [e for e in r.RelatedObjects if not e.is_a("IfcPort")] ] + if self.file.schema == "IFC4X3": + rel_aggregates += [r for r in self.file.by_type("IfcRelAdheresToElement")] if len(rel_aggregates) > 10000: # More than 10,000 collections makes Blender unhappy @@ -1663,7 +1666,9 @@ class IfcImporter: aggregates: dict[str, dict] = {} for rel_aggregate in rel_aggregates: - element: ifcopenshell.entity_instance = rel_aggregate.RelatingObject + element: ifcopenshell.entity_instance = getattr(rel_aggregate, "RelatingObject", None) or getattr( + rel_aggregate, "RelatingElement" + ) collection = bpy.data.collections.new(tool.Loader.get_name(element)) aggregates[element.GlobalId] = {"element": element, "collection": collection} self.collections[element.GlobalId] = collection @@ -1764,6 +1769,9 @@ class IfcImporter: elif getattr(element, "Nests", None) and not element.is_a("IfcPort"): nest = ifcopenshell.util.element.get_nest(element) return self.collections[nest.GlobalId].objects.link(obj) + elif element.is_a("IfcSurfaceFeature") and self.file.schema == "IFC4X3": + adherend = element.AdheresToElement[0].RelatingElement + return self.collections[adherend.GlobalId].objects.link(obj) return self.place_object_in_spatial_decomposition_collection(element, obj) diff --git a/src/blenderbim/blenderbim/tool/collector.py b/src/blenderbim/blenderbim/tool/collector.py index 095d56ea1d..738b7d1cc6 100644 --- a/src/blenderbim/blenderbim/tool/collector.py +++ b/src/blenderbim/blenderbim/tool/collector.py @@ -187,6 +187,9 @@ class Collector(blenderbim.core.tool.Collector): if any(e for e in element.IsNestedBy[0].RelatedObjects if not e.is_a("IfcPort")): return cls._create_own_collection(obj) + if getattr(element, "HasSurfaceFeatures", None): + return cls._create_own_collection(obj) + @classmethod def _get_collection(cls, element: ifcopenshell.entity_instance, obj: bpy.types.Object) -> bpy.types.Collection: """get or create collection for the element based on it's type""" @@ -247,6 +250,13 @@ class Collector(blenderbim.core.tool.Collector): if collection: return collection + if element.is_a("IfcSurfaceFeature") and element.file.schema == "IFC4X3": + adherend = element.AdheresToElement[0].RelatingElement + adherend_obj = tool.Ifc.get_object(adherend) + collection = adherend_obj.BIMObjectProperties.collection + if collection: + return collection + if element.is_a("IfcProject"): return bpy.context.scene.collection