mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
Error on tessellation request in IFC2X3
IfcTriangulatedFaceSet/IfcPolygonalFaceSet were introduced in Fix #7992: IFC4 and do not exist in IFC2X3. Previously, requesting an IfcTessellatedFaceSet representation in an IFC2X3 file silently fell back to a faceted brep after unassigning material sets. Add a guard in the update_representation operator (user-facing error) and in the add_representation API (ValueError) so the unsupported request is caught instead of failing silently. Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -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
|
objs = [bpy.data.objects[obj_name]] if obj_name else context.selected_objects
|
||||||
self.file = tool.Ifc.get()
|
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:
|
for obj in objs:
|
||||||
# TODO: write unit tests to see how this bulk operation handles
|
# TODO: write unit tests to see how this bulk operation handles
|
||||||
# contradictory ifc_representation_class values and when
|
# contradictory ifc_representation_class values and when
|
||||||
|
|||||||
@@ -121,6 +121,12 @@ class Usecase:
|
|||||||
blender_object: bpy.types.Object
|
blender_object: bpy.types.Object
|
||||||
|
|
||||||
def execute(self) -> Union[ifcopenshell.entity_instance, None]:
|
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.is_manifold = None
|
||||||
self.coordinate_offset = self.settings["coordinate_offset"]
|
self.coordinate_offset = self.settings["coordinate_offset"]
|
||||||
self.geometry = self.settings["geometry"]
|
self.geometry = self.settings["geometry"]
|
||||||
|
|||||||
Reference in New Issue
Block a user