mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
export_mesh_to_tessellation to consider empty material slots #6453
This commit is contained in:
@@ -1931,6 +1931,7 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
def export_mesh_to_tessellation(
|
def export_mesh_to_tessellation(
|
||||||
cls, obj: bpy.types.Object, ifc_context: ifcopenshell.entity_instance
|
cls, obj: bpy.types.Object, ifc_context: ifcopenshell.entity_instance
|
||||||
) -> ifcopenshell.entity_instance:
|
) -> ifcopenshell.entity_instance:
|
||||||
|
ifc_file = tool.Ifc.get()
|
||||||
builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get())
|
builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get())
|
||||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
items = []
|
items = []
|
||||||
@@ -1946,7 +1947,10 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
items.append(item)
|
items.append(item)
|
||||||
material_index = mesh.polygons[0].material_index
|
material_index = mesh.polygons[0].material_index
|
||||||
if materials := list(mesh.materials):
|
if materials := list(mesh.materials):
|
||||||
|
# TODO: we don't account for multiple materials if they're not on loose parts.
|
||||||
material = materials[material_index]
|
material = materials[material_index]
|
||||||
|
if not material:
|
||||||
|
continue
|
||||||
if not (style := tool.Ifc.get_entity(material)):
|
if not (style := tool.Ifc.get_entity(material)):
|
||||||
style = ifcopenshell.api.run("style.add_style", tool.Ifc.get(), name=material.name)
|
style = ifcopenshell.api.run("style.add_style", tool.Ifc.get(), name=material.name)
|
||||||
if material.use_nodes:
|
if material.use_nodes:
|
||||||
|
|||||||
Reference in New Issue
Block a user