mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Fix bug where copying elements didn't ensure that material usages were unique
This commit is contained in:
@@ -33,6 +33,10 @@ class Usecase:
|
||||
continue
|
||||
elif inverse.is_a("IfcRelFillsElement"):
|
||||
continue
|
||||
elif inverse.is_a("IfcRelAssociatesMaterial") and "Usage" in inverse.RelatingMaterial.is_a():
|
||||
inverse = ifcopenshell.util.element.copy(self.file, inverse)
|
||||
inverse.RelatingMaterial = ifcopenshell.util.element.copy(self.file, inverse.RelatingMaterial)
|
||||
inverse.RelatedObjects = [to_element]
|
||||
else:
|
||||
for i, value in enumerate(inverse):
|
||||
if value == from_element:
|
||||
|
||||
@@ -108,3 +108,11 @@ class TestCopyClass(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run("void.add_filling", self.file, opening=opening, element=door)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=door)
|
||||
assert not new.FillsVoids
|
||||
|
||||
def test_copying_material_set_usages(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = self.file.createIfcMaterialLayerSetUsage()
|
||||
self.file.createIfcRelAssociatesMaterial(RelatedObjects=[element], RelatingMaterial=material)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
assert new.HasAssociations[0].RelatingMaterial != element.HasAssociations[0].RelatingMaterial
|
||||
assert new.HasAssociations[0].RelatingMaterial.is_a("IfcMaterialLayerSetUsage")
|
||||
|
||||
Reference in New Issue
Block a user