mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
#2188 support displaying inherited materials
This commit is contained in:
@@ -78,9 +78,22 @@ class ObjectMaterialData:
|
||||
def load(cls):
|
||||
cls.data = {
|
||||
"materials": cls.materials(),
|
||||
"type_material": cls.type_material(),
|
||||
}
|
||||
cls.is_loaded = True
|
||||
|
||||
@classmethod
|
||||
def materials(cls):
|
||||
return sorted([(str(m.id()), m.Name or "Unnamed", "") for m in tool.Ifc.get().by_type("IfcMaterial")], key=lambda x: x[1])
|
||||
|
||||
@classmethod
|
||||
def type_material(cls):
|
||||
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||
element_type = ifcopenshell.util.element.get_type(element)
|
||||
if element_type != element:
|
||||
material = ifcopenshell.util.element.get_material(element_type)
|
||||
if material.is_a() in ("IfcMaterialLayerSetUsage", "IfcMaterialLayerSet"):
|
||||
name_attr = "LayerSetName"
|
||||
else:
|
||||
name_attr = "Name"
|
||||
return getattr(material, name_attr, "Unnamed")
|
||||
|
||||
@@ -141,6 +141,10 @@ class BIM_PT_object_material(Panel):
|
||||
row.operator("bim.add_material", icon="ADD", text="").obj = ""
|
||||
return
|
||||
|
||||
if ObjectMaterialData.data["type_material"]:
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="Inherited Material: " + ObjectMaterialData.data["type_material"], icon="FILE_PARENT")
|
||||
|
||||
if self.product_data:
|
||||
if self.product_data["type"] == "IfcMaterialConstituentSet":
|
||||
self.material_set_id = self.product_data["id"]
|
||||
|
||||
@@ -147,7 +147,7 @@ class BIM_PT_object_psets(Panel):
|
||||
draw_psetqto_ui(context, pset["id"], pset, props, self.layout, "Object")
|
||||
|
||||
if ObjectPsetsData.data["inherited_psets"]:
|
||||
self.layout.label(text="Inherited Psets:")
|
||||
self.layout.label(text="Inherited Psets:", icon="FILE_PARENT")
|
||||
for pset in ObjectPsetsData.data["inherited_psets"]:
|
||||
draw_psetqto_ui(context, pset["id"], pset, props, self.layout, "Object")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user