diff --git a/src/bonsai/bonsai/bim/module/geometry/operator.py b/src/bonsai/bonsai/bim/module/geometry/operator.py index 3a6b911c15..05a7b43625 100644 --- a/src/bonsai/bonsai/bim/module/geometry/operator.py +++ b/src/bonsai/bonsai/bim/module/geometry/operator.py @@ -546,6 +546,13 @@ class UpdateRepresentation(bpy.types.Operator, tool.Ifc.Operator): objs = [bpy.data.objects[obj_name]] if obj_name else context.selected_objects self.file = tool.Ifc.get() + # Tessellated face sets (IfcTriangulatedFaceSet/IfcPolygonalFaceSet) were + # introduced in IFC4 and do not exist in IFC2X3. Catch this early so we + # don't silently fall back to a faceted brep after stripping materials. + if self.ifc_representation_class == "IfcTessellatedFaceSet" and self.file.schema == "IFC2X3": + self.report({"ERROR"}, "Tessellated face sets are not supported in IFC2X3.") + return {"CANCELLED"} + for obj in objs: # TODO: write unit tests to see how this bulk operation handles # contradictory ifc_representation_class values and when diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py index e756cb07cf..16dc7a8345 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py @@ -121,6 +121,12 @@ class Usecase: blender_object: bpy.types.Object def execute(self) -> Union[ifcopenshell.entity_instance, None]: + # IfcTriangulatedFaceSet/IfcPolygonalFaceSet were introduced in IFC4 and + # do not exist in IFC2X3. Without this guard create_mesh_representation() + # silently falls back to a faceted brep, ignoring the requested class. + if self.settings["ifc_representation_class"] == "IfcTessellatedFaceSet" and self.file.schema == "IFC2X3": + raise ValueError("Tessellated face sets (IfcTessellatedFaceSet) are not supported in IFC2X3.") + self.is_manifold = None self.coordinate_offset = self.settings["coordinate_offset"] self.geometry = self.settings["geometry"]