mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 10:06:57 +00:00
root.remove_product to remove IfcRelFlowControlElements
This commit is contained in:
@@ -167,4 +167,9 @@ class Usecase:
|
|||||||
self.file.remove(inverse)
|
self.file.remove(inverse)
|
||||||
elif len(inverse.RelatedObjects) == 1:
|
elif len(inverse.RelatedObjects) == 1:
|
||||||
self.file.remove(inverse)
|
self.file.remove(inverse)
|
||||||
|
elif inverse.is_a("IfcRelFlowControlElements"):
|
||||||
|
if inverse.RelatingFlowElement == self.settings["product"]:
|
||||||
|
self.file.remove(inverse)
|
||||||
|
elif inverse.RelatedControlElements == (self.settings["product"],):
|
||||||
|
self.file.remove(inverse)
|
||||||
self.file.remove(self.settings["product"])
|
self.file.remove(self.settings["product"])
|
||||||
|
|||||||
@@ -391,3 +391,45 @@ class TestRemoveProduct(test.bootstrap.IFC4):
|
|||||||
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=element, related_object=annotation)
|
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=element, related_object=annotation)
|
||||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||||
assert not self.file.by_type("IfcRelAssignsToProduct")
|
assert not self.file.by_type("IfcRelAssignsToProduct")
|
||||||
|
|
||||||
|
def test_removing_flow_control_elements(self):
|
||||||
|
flow_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||||
|
flow_control = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcController")
|
||||||
|
flow_control1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcController")
|
||||||
|
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"system.assign_flow_control",
|
||||||
|
self.file,
|
||||||
|
related_flow_control=flow_control,
|
||||||
|
relating_flow_element=flow_element,
|
||||||
|
)
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"system.assign_flow_control",
|
||||||
|
self.file,
|
||||||
|
related_flow_control=flow_control1,
|
||||||
|
relating_flow_element=flow_element,
|
||||||
|
)
|
||||||
|
ifcopenshell.api.run("root.remove_product", self.file, product=flow_control)
|
||||||
|
assert len(self.file.by_type("IfcRelFlowControlElements")) == 1
|
||||||
|
ifcopenshell.api.run("root.remove_product", self.file, product=flow_control1)
|
||||||
|
assert not self.file.by_type("IfcRelFlowControlElements")
|
||||||
|
|
||||||
|
def test_removing_flow_element_with_flow_controls(self):
|
||||||
|
flow_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||||
|
flow_control = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcController")
|
||||||
|
flow_control1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcController")
|
||||||
|
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"system.assign_flow_control",
|
||||||
|
self.file,
|
||||||
|
related_flow_control=flow_control,
|
||||||
|
relating_flow_element=flow_element,
|
||||||
|
)
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"system.assign_flow_control",
|
||||||
|
self.file,
|
||||||
|
related_flow_control=flow_control1,
|
||||||
|
relating_flow_element=flow_element,
|
||||||
|
)
|
||||||
|
ifcopenshell.api.run("root.remove_product", self.file, product=flow_element)
|
||||||
|
assert not self.file.by_type("IfcRelFlowControlElements")
|
||||||
|
|||||||
Reference in New Issue
Block a user