mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
#2188 support displaying inherited materials
This commit is contained in:
@@ -78,9 +78,22 @@ class ObjectMaterialData:
|
|||||||
def load(cls):
|
def load(cls):
|
||||||
cls.data = {
|
cls.data = {
|
||||||
"materials": cls.materials(),
|
"materials": cls.materials(),
|
||||||
|
"type_material": cls.type_material(),
|
||||||
}
|
}
|
||||||
cls.is_loaded = True
|
cls.is_loaded = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def materials(cls):
|
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])
|
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 = ""
|
row.operator("bim.add_material", icon="ADD", text="").obj = ""
|
||||||
return
|
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:
|
||||||
if self.product_data["type"] == "IfcMaterialConstituentSet":
|
if self.product_data["type"] == "IfcMaterialConstituentSet":
|
||||||
self.material_set_id = self.product_data["id"]
|
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")
|
draw_psetqto_ui(context, pset["id"], pset, props, self.layout, "Object")
|
||||||
|
|
||||||
if ObjectPsetsData.data["inherited_psets"]:
|
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"]:
|
for pset in ObjectPsetsData.data["inherited_psets"]:
|
||||||
draw_psetqto_ui(context, pset["id"], pset, props, self.layout, "Object")
|
draw_psetqto_ui(context, pset["id"], pset, props, self.layout, "Object")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user