Material UI now prompts to add a profile if none exist in your library

This commit is contained in:
Dion Moult
2022-11-03 23:44:47 +11:00
parent 32e00f6d49
commit 5acbf4658f
2 changed files with 13 additions and 6 deletions
@@ -179,6 +179,8 @@ class ObjectMaterialData:
for item in items or []: for item in items or []:
data = {"id": item.id(), "name": item.Name or "Unnamed", "icon": icon} data = {"id": item.id(), "name": item.Name or "Unnamed", "icon": icon}
if item.is_a("IfcMaterialProfile") and not item.Name:
data["name"] = item.Profile.ProfileName or "Unnamed"
if item.is_a("IfcMaterialLayer"): if item.is_a("IfcMaterialLayer"):
data["name"] += f" ({item.LayerThickness})" data["name"] += f" ({item.LayerThickness})"
if not item.is_a("IfcMaterialList"): if not item.is_a("IfcMaterialList"):
@@ -195,6 +195,11 @@ class BIM_PT_object_material(Panel):
blenderbim.bim.helper.draw_attributes(self.props.material_set_attributes, self.layout) blenderbim.bim.helper.draw_attributes(self.props.material_set_attributes, self.layout)
blenderbim.bim.helper.draw_attributes(self.props.material_set_usage_attributes, self.layout) blenderbim.bim.helper.draw_attributes(self.props.material_set_usage_attributes, self.layout)
if ObjectMaterialData.data["set_item_name"] == "profile" and not self.mprops.profiles:
row = self.layout.row(align=True)
row.label(text="No Profiles Available")
row.operator("bim.add_profile_def", icon="ADD", text="")
else:
row = self.layout.row(align=True) row = self.layout.row(align=True)
if ObjectMaterialData.data["set_item_name"] == "profile": if ObjectMaterialData.data["set_item_name"] == "profile":
row.prop(self.mprops, "profiles", icon="ITALIC", text="") row.prop(self.mprops, "profiles", icon="ITALIC", text="")