mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
You can now copy a material list
This commit is contained in:
@@ -63,6 +63,8 @@ def copy_material(file: ifcopenshell.file, material: ifcopenshell.entity_instanc
|
|||||||
return new
|
return new
|
||||||
elif material.is_a("IfcMaterialProfile"):
|
elif material.is_a("IfcMaterialProfile"):
|
||||||
return _copy_material_with_inverses(file, material)
|
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):
|
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("IfcMaterial")) == 1
|
||||||
assert len(self.file.by_type("IfcProfileDef")) == 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):
|
class TestCopyMaterialIFC2X3(test.bootstrap.IFC2X3, TestCopyMaterial):
|
||||||
def test_copy_a_material_constituent_set(self):
|
def test_copy_a_material_constituent_set(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user