mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
Fix bug where copying a container also copied its contents
This commit is contained in:
@@ -27,6 +27,8 @@ class Usecase:
|
|||||||
inverse.RelatingPropertyDefinition = pset
|
inverse.RelatingPropertyDefinition = pset
|
||||||
elif inverse.is_a("IfcRelAggregates") and inverse.RelatingObject == from_element:
|
elif inverse.is_a("IfcRelAggregates") and inverse.RelatingObject == from_element:
|
||||||
continue
|
continue
|
||||||
|
elif inverse.is_a("IfcRelContainedInSpatialStructure") and inverse.RelatingStructure == from_element:
|
||||||
|
continue
|
||||||
elif inverse.is_a("IfcRelFillsElement"):
|
elif inverse.is_a("IfcRelFillsElement"):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -24,6 +24,29 @@ class TestCopyClass(test.bootstrap.IFC4):
|
|||||||
assert pset.HasProperties[0].Name == new_pset.HasProperties[0].Name
|
assert pset.HasProperties[0].Name == new_pset.HasProperties[0].Name
|
||||||
assert pset.HasProperties[0].NominalValue.wrappedValue == new_pset.HasProperties[0].NominalValue.wrappedValue
|
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):
|
def test_copying_an_aggregate_only_and_not_its_decomposition(self):
|
||||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
|
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcElementAssembly")
|
||||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
|
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBeam")
|
||||||
|
|||||||
Reference in New Issue
Block a user