The material manager now groups materials into categories

This commit is contained in:
Dion Moult
2022-05-08 15:48:09 +10:00
parent 1f3ba3d09d
commit c8d6d12442
7 changed files with 113 additions and 20 deletions
@@ -118,3 +118,18 @@ Scenario: Select by material
And the variable "material" is "{ifc}.by_type('IfcMaterial')[0].id()"
When I press "bim.select_by_material(material={material})"
Then nothing happens
Scenario: Expand material category
Given an empty IFC project
And I press "bim.load_materials"
And I press "bim.add_material(obj='')"
When I press "bim.expand_material_category(category='')"
Then nothing happens
Scenario: Contract material category
Given an empty IFC project
And I press "bim.load_materials"
And I press "bim.add_material(obj='')"
And I press "bim.expand_material_category(category='')"
When I press "bim.contract_material_category(category='')"
Then nothing happens
+20 -5
View File
@@ -84,15 +84,30 @@ class TestGetName(NewFile):
class TestImportMaterialDefinitions(NewFile):
def test_import_materials(self):
def test_import_materials_grouped_by_categories(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
material = ifc.createIfcMaterial(Name="Name")
material = ifc.createIfcMaterial(Name="Name", Category="Category")
subject.import_material_definitions("IfcMaterial")
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
assert props.materials[0].ifc_definition_id == 0
assert props.materials[0].name == "Category"
assert props.materials[0].is_category is True
assert props.materials[0].is_expanded is False
assert len(props.materials) == 1
def test_importing_expanded_material_categories(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
material = ifc.createIfcMaterial(Name="Name", Category="Category")
subject.import_material_definitions("IfcMaterial")
props = bpy.context.scene.BIMMaterialProperties
props.materials[0].is_expanded = True
subject.import_material_definitions("IfcMaterial")
assert len(props.materials) == 2
assert props.materials[1].ifc_definition_id == material.id()
assert props.materials[1].name == "Name"
assert props.materials[1].total_elements == 0
def test_import_material_layer_sets(self):
ifc = ifcopenshell.file()