mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
spatial.dereference_structure - support batching #4474
This commit is contained in:
@@ -26,28 +26,42 @@ class TestDereferenceStructure(test.bootstrap.IFC4):
|
||||
def test_removing_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.reference_structure", self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.run("spatial.dereference_structure", self.file, product=subelement, relating_structure=element)
|
||||
subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"spatial.reference_structure", self.file, products=[subelement, subelement2], relating_structure=element
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"spatial.dereference_structure", self.file, products=[subelement, subelement2], relating_structure=element
|
||||
)
|
||||
assert ifcopenshell.util.element.get_referenced_structures(subelement) == []
|
||||
assert len(self.file.by_type("IfcRelReferencedInSpatialStructure")) == 0
|
||||
|
||||
def test_doing_nothing_if_no_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.dereference_structure", self.file, product=subelement, relating_structure=element)
|
||||
subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"spatial.dereference_structure", self.file, products=[subelement, subelement2], relating_structure=element
|
||||
)
|
||||
assert ifcopenshell.util.element.get_referenced_structures(subelement) == []
|
||||
assert ifcopenshell.util.element.get_referenced_structures(subelement2) == []
|
||||
|
||||
def test_updating_the_rel_when_a_reference_is_removed_with_multipled_elements(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
subelement2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("spatial.reference_structure", self.file, products=[subelement1], relating_structure=element)
|
||||
ifcopenshell.api.run("spatial.reference_structure", self.file, products=[subelement2], relating_structure=element)
|
||||
ifcopenshell.api.run("spatial.dereference_structure", self.file, product=subelement1, relating_structure=element)
|
||||
assert self.file.by_type("IfcRelReferencedInSpatialStructure")[0].RelatedElements == (subelement2,)
|
||||
subelement3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"spatial.reference_structure", self.file, products=[subelement1], relating_structure=element
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"spatial.reference_structure", self.file, products=[subelement2, subelement3], relating_structure=element
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"spatial.dereference_structure", self.file, products=[subelement1, subelement2], relating_structure=element
|
||||
)
|
||||
assert element.ReferencesElements[0].RelatedElements == (subelement3,)
|
||||
|
||||
def test_deleting_the_rel_when_a_container_is_removed_with_no_elements(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.reference_structure", self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.run("spatial.dereference_structure", self.file, product=subelement, relating_structure=element)
|
||||
assert len(self.file.by_type("IfcRelReferencedInSpatialStructure")) == 0
|
||||
|
||||
class TestDereferenceStructureIFC2X3(test.bootstrap.IFC2X3, TestDereferenceStructure):
|
||||
pass
|
||||
|
||||
@@ -280,3 +280,11 @@ class TestTemporarySupportForDeprecatedAPIArguments(test.bootstrap.IFC4):
|
||||
)
|
||||
assert ifcopenshell.util.element.get_referenced_structures(subelement) == [element]
|
||||
assert rel.is_a("IfcRelReferencedInSpatialStructure")
|
||||
|
||||
@deprecation_check
|
||||
def test_removing_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.reference_structure", self.file, products=[subelement], relating_structure=element)
|
||||
ifcopenshell.api.run("spatial.dereference_structure", self.file, product=subelement, relating_structure=element)
|
||||
assert ifcopenshell.util.element.get_referenced_structures(subelement) == []
|
||||
|
||||
Reference in New Issue
Block a user