The material manager now shows total elements used by a material

This commit is contained in:
Dion Moult
2022-03-22 12:50:10 +11:00
parent 0c8273eb70
commit 9b9f0058f9
6 changed files with 87 additions and 0 deletions
@@ -114,6 +114,7 @@ def get_material_types(self, context):
class Material(PropertyGroup):
name: StringProperty(name="Name")
ifc_definition_id: IntProperty(name="IFC Definition ID")
total_elements: IntProperty(name="Total Elements")
class BIMMaterialProperties(PropertyGroup):
@@ -389,3 +389,6 @@ class BIM_UL_materials(UIList):
if item:
row = layout.row(align=True)
row.label(text=item.name)
row2 = row.row()
row2.alignment = "RIGHT"
row2.label(text=str(item.total_elements))
@@ -61,6 +61,7 @@ class Material(blenderbim.core.tool.Material):
new.name = "Unnamed"
else:
new.name = material.Name or "Unnamed"
new.total_elements = len(set(ifcopenshell.util.element.get_elements_by_material(tool.Ifc.get(), material)))
@classmethod
def is_editing_materials(cls):
@@ -82,6 +82,7 @@ class TestImportMaterialDefinitions(NewFile):
props = bpy.context.scene.BIMMaterialProperties
assert props.materials[0].ifc_definition_id == material.id()
assert props.materials[0].name == "Name"
assert props.materials[0].total_elements == 0
def test_import_material_layer_sets(self):
ifc = ifcopenshell.file()
@@ -91,6 +92,7 @@ class TestImportMaterialDefinitions(NewFile):
props = bpy.context.scene.BIMMaterialProperties
assert props.materials[0].ifc_definition_id == material.id()
assert props.materials[0].name == "Name"
assert props.materials[0].total_elements == 0
def test_import_material_profile_sets(self):
ifc = ifcopenshell.file()
@@ -100,6 +102,7 @@ class TestImportMaterialDefinitions(NewFile):
props = bpy.context.scene.BIMMaterialProperties
assert props.materials[0].ifc_definition_id == material.id()
assert props.materials[0].name == "Name"
assert props.materials[0].total_elements == 0
def test_import_material_constituent_sets(self):
ifc = ifcopenshell.file()
@@ -109,6 +112,7 @@ class TestImportMaterialDefinitions(NewFile):
props = bpy.context.scene.BIMMaterialProperties
assert props.materials[0].ifc_definition_id == material.id()
assert props.materials[0].name == "Name"
assert props.materials[0].total_elements == 0
def test_import_material_lists(self):
ifc = ifcopenshell.file()
@@ -118,6 +122,7 @@ class TestImportMaterialDefinitions(NewFile):
props = bpy.context.scene.BIMMaterialProperties
assert props.materials[0].ifc_definition_id == material.id()
assert props.materials[0].name == "Unnamed"
assert props.materials[0].total_elements == 0
class TestIsEditingMaterials(NewFile):