From 99c752904a517f9db893bd8866986b3376a2c854 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 12 Dec 2024 18:14:28 +0500 Subject: [PATCH] Fallback to add_representation for mesh curves #5870 (after 42f32e3) --- src/bonsai/bonsai/bim/module/root/operator.py | 11 +++++++++-- src/bonsai/bonsai/tool/geometry.py | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/root/operator.py b/src/bonsai/bonsai/bim/module/root/operator.py index 5d15356e3e..acc0133782 100644 --- a/src/bonsai/bonsai/bim/module/root/operator.py +++ b/src/bonsai/bonsai/bim/module/root/operator.py @@ -211,6 +211,12 @@ class AssignClass(bpy.types.Operator, tool.Ifc.Operator): ) continue + should_add_representation = self.should_add_representation + export_mesh_to_tesselation = False + if self.should_add_representation and isinstance(obj.data, bpy.types.Mesh) and obj.data.polygons: + should_add_representation = False + export_mesh_to_tesselation = True + element = core.assign_class( tool.Ifc, tool.Collector, @@ -218,11 +224,12 @@ class AssignClass(bpy.types.Operator, tool.Ifc.Operator): obj=obj, ifc_class=ifc_class, predefined_type=predefined_type, - should_add_representation=False, + should_add_representation=should_add_representation, context=ifc_context, ifc_representation_class=self.ifc_representation_class, ) - if self.should_add_representation and obj.data and len(obj.data.vertices): + + if export_mesh_to_tesselation: representation = tool.Geometry.export_mesh_to_tessellation(obj, ifc_context) ifcopenshell.api.geometry.assign_representation(tool.Ifc.get(), element, representation) bonsai.core.geometry.switch_representation( diff --git a/src/bonsai/bonsai/tool/geometry.py b/src/bonsai/bonsai/tool/geometry.py index 47f8a8d47e..e396495091 100644 --- a/src/bonsai/bonsai/tool/geometry.py +++ b/src/bonsai/bonsai/tool/geometry.py @@ -1719,7 +1719,9 @@ class Geometry(bonsai.core.tool.Geometry): data["ios_item_ids"] = [i["item"].id() for i in ifcopenshell.util.representation.resolve_items(representation)] @classmethod - def export_mesh_to_tessellation(cls, obj: bpy.types.Object, ifc_context) -> ifcopenshell.entity_instance: + def export_mesh_to_tessellation( + cls, obj: bpy.types.Object, ifc_context: ifcopenshell.entity_instance + ) -> ifcopenshell.entity_instance: builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get()) unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) items = []