You can now copy a material list

This commit is contained in:
Dion Moult
2024-05-25 15:13:36 +10:00
parent d85f9af790
commit 16c5fd56ca
2 changed files with 13 additions and 0 deletions
@@ -63,6 +63,8 @@ def copy_material(file: ifcopenshell.file, material: ifcopenshell.entity_instanc
return new
elif material.is_a("IfcMaterialProfile"):
return _copy_material_with_inverses(file, material)
elif material.is_a("IfcMaterialList"):
return _copy_material_with_inverses(file, material)
def _copy_material_with_inverses(file, material):
@@ -136,6 +136,17 @@ class TestCopyMaterial(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcMaterial")) == 1
assert len(self.file.by_type("IfcProfileDef")) == 1
def test_copy_a_material_list(self):
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialList")
ifcopenshell.api.run("material.add_list_item", self.file, material_list=material_set, material=material)
new = ifcopenshell.api.run("material.copy_material", self.file, material=material_set)
assert new != material_set
assert new.Materials[0] == material
assert len(self.file.by_type("IfcMaterialList")) == 2
assert len(self.file.by_type("IfcMaterial")) == 1
class TestCopyMaterialIFC2X3(test.bootstrap.IFC2X3, TestCopyMaterial):
def test_copy_a_material_constituent_set(self):