Fix bug when casting to tessellation for invalid IFCs which don't use material sets properly.

This commit is contained in:
Dion Moult
2023-09-08 15:52:44 +10:00
parent 1a59b4913e
commit 01c1023af2
@@ -272,7 +272,8 @@ class UpdateRepresentation(bpy.types.Operator, Operator):
if self.ifc_representation_class == "IfcTessellatedFaceSet":
# We are explicitly casting to a tessellation, so remove all parametric materials.
element_type = ifcopenshell.util.element.get_type(product)
ifcopenshell.api.run("material.unassign_material", tool.Ifc.get(), product=element_type)
if element_type: # Some invalid IFCs use material sets without a type.
ifcopenshell.api.run("material.unassign_material", tool.Ifc.get(), product=element_type)
ifcopenshell.api.run("material.unassign_material", tool.Ifc.get(), product=product)
else:
# These objects are parametrically based on an axis and should not be modified as a mesh