Fix bug in 4c93270ad for IfcMaterialLayers

This commit is contained in:
Andrej730
2024-10-29 15:11:22 +05:00
parent ff0fe0db06
commit bb23d74ce3
2 changed files with 15 additions and 1 deletions
@@ -888,5 +888,8 @@ class SelectMaterialInMaterialsUI(bpy.types.Operator):
item_index, _ = material_item
props.active_material_index = item_index
self.report({"INFO"}, f"Material '{material.Name}' is selected in Materials UI.")
self.report(
{"INFO"},
f"Material '{tool.Material.get_material_name(material) or 'Unnamed'}' is selected in Materials UI.",
)
return {"FINISHED"}
+11
View File
@@ -429,3 +429,14 @@ class Material(bonsai.core.tool.Material):
i += cls.purge_unused_materials()
return i
@classmethod
def get_material_name(cls, material: ifcopenshell.entity_instance) -> Union[str, None]:
ifc_class = material.is_a()
if ifc_class == "IfcMaterialList":
return None
elif ifc_class == "IfcMaterialLayerSet":
# Optional IfcLabel.
return material.LayerSetName
# Optional IfcLabel except for IfcMaterial.
return material.Name