Fallback to add_representation for mesh curves #5870 (after 42f32e3)

This commit is contained in:
Andrej730
2024-12-12 18:14:28 +05:00
parent 8574057340
commit 99c752904a
2 changed files with 12 additions and 3 deletions
@@ -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(
+3 -1
View File
@@ -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 = []