mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix bug where copying a container also copied its contents
This commit is contained in:
@@ -24,6 +24,29 @@ class TestCopyClass(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[0].Name == new_pset.HasProperties[0].Name
|
||||
assert pset.HasProperties[0].NominalValue.wrappedValue == new_pset.HasProperties[0].NominalValue.wrappedValue
|
||||
|
||||
def test_copying_a_container_only_and_not_its_contents(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, product=subelement, relating_structure=element)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
assert element.ContainsElements
|
||||
assert not new.ContainsElements
|
||||
|
||||
def test_copying_contents_of_a_container(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("spatial.assign_container", self.file, product=subelement, relating_structure=element)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=subelement)
|
||||
assert new.ContainedInStructure[0].RelatingStructure == element
|
||||
|
||||
def test_copying_a_container_only_and_not_its_decomposition(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuildingStorey")
|
||||
ifcopenshell.api.run("aggregate.assign_object", self.file, product=subelement, relating_object=element)
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
assert element.IsDecomposedBy
|
||||
assert not new.IsDecomposedBy
|
||||
|
||||
def test_copying_an_aggregate_only_and_not_its_decomposition(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
|
||||
|
||||
Reference in New Issue
Block a user