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 []:
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"):
data["name"] += f" ({item.LayerThickness})"
if not item.is_a("IfcMaterialList"):
@@ -195,12 +195,17 @@ 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_usage_attributes, self.layout)
row = self.layout.row(align=True)
if ObjectMaterialData.data["set_item_name"] == "profile":
row.prop(self.mprops, "profiles", icon="ITALIC", text="")
prop_with_search(row, self.props, "material", icon="MATERIAL", text="")
op = row.operator(f"bim.add_{ObjectMaterialData.data['set_item_name']}", icon="ADD", text="")
setattr(op, f"{ObjectMaterialData.data['set_item_name']}_set", ObjectMaterialData.data["set"]["id"])
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)
if ObjectMaterialData.data["set_item_name"] == "profile":
row.prop(self.mprops, "profiles", icon="ITALIC", text="")
prop_with_search(row, self.props, "material", icon="MATERIAL", text="")
op = row.operator(f"bim.add_{ObjectMaterialData.data['set_item_name']}", icon="ADD", text="")
setattr(op, f"{ObjectMaterialData.data['set_item_name']}_set", ObjectMaterialData.data["set"]["id"])
total_items = len(ObjectMaterialData.data["set_items"])
for index, set_item in enumerate(ObjectMaterialData.data["set_items"]):