From f08f9ad310daeee9a19575296698613be1b38dcc Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 28 Mar 2025 12:01:04 +0500 Subject: [PATCH] export_mesh_to_tessellation to consider empty material slots #6453 --- src/bonsai/bonsai/tool/geometry.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bonsai/bonsai/tool/geometry.py b/src/bonsai/bonsai/tool/geometry.py index 2975bbdbcb..a386132cbb 100644 --- a/src/bonsai/bonsai/tool/geometry.py +++ b/src/bonsai/bonsai/tool/geometry.py @@ -1931,6 +1931,7 @@ class Geometry(bonsai.core.tool.Geometry): def export_mesh_to_tessellation( cls, obj: bpy.types.Object, ifc_context: ifcopenshell.entity_instance ) -> ifcopenshell.entity_instance: + ifc_file = tool.Ifc.get() builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get()) unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) items = [] @@ -1946,7 +1947,10 @@ class Geometry(bonsai.core.tool.Geometry): items.append(item) material_index = mesh.polygons[0].material_index if materials := list(mesh.materials): + # TODO: we don't account for multiple materials if they're not on loose parts. material = materials[material_index] + if not material: + continue if not (style := tool.Ifc.get_entity(material)): style = ifcopenshell.api.run("style.add_style", tool.Ifc.get(), name=material.name) if material.use_nodes: