mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-18 03:19:53 +00:00
Support other voiding IfcFeatureElementSubtraction elements #3889
Support other voiding IfcFeatureElementSubtraction besides IfcOpeningElement.
This commit is contained in:
@@ -801,7 +801,7 @@ class EditOpenings(Operator, tool.Ifc.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def get_all_building_objects_of_similar_openings(self, opening):
|
def get_all_building_objects_of_similar_openings(self, opening):
|
||||||
if not opening.HasFillings:
|
if not opening.is_a("IfcOpeningElement") or not opening.HasFillings:
|
||||||
return []
|
return []
|
||||||
results = set()
|
results = set()
|
||||||
for rel in opening.HasFillings:
|
for rel in opening.HasFillings:
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ class Usecase:
|
|||||||
elif inverse.is_a("IfcRelVoidsElement") and inverse.RelatingBuildingElement == from_element:
|
elif inverse.is_a("IfcRelVoidsElement") and inverse.RelatingBuildingElement == from_element:
|
||||||
opening = inverse.RelatedOpeningElement
|
opening = inverse.RelatedOpeningElement
|
||||||
# We don't copy filled openings, since there is no guarantee the filling is also copied
|
# We don't copy filled openings, since there is no guarantee the filling is also copied
|
||||||
if not opening.HasFillings:
|
if not opening.is_a("IfcOpeningElement") or not opening.HasFillings:
|
||||||
new_opening = ifcopenshell.api.run("root.copy_class", self.file, product=opening)
|
new_opening = ifcopenshell.api.run("root.copy_class", self.file, product=opening)
|
||||||
new_opening.VoidsElements[0].RelatingBuildingElement = to_element
|
new_opening.VoidsElements[0].RelatingBuildingElement = to_element
|
||||||
if new_opening.ObjectPlacement and new_opening.ObjectPlacement.is_a("IfcLocalPlacement"):
|
if new_opening.ObjectPlacement and new_opening.ObjectPlacement.is_a("IfcLocalPlacement"):
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class Usecase:
|
|||||||
def execute(self):
|
def execute(self):
|
||||||
for rel in self.settings["opening"].VoidsElements:
|
for rel in self.settings["opening"].VoidsElements:
|
||||||
self.file.remove(rel)
|
self.file.remove(rel)
|
||||||
for rel in self.settings["opening"].HasFillings:
|
if self.settings["opening"].is_a("IfcOpeningElement"):
|
||||||
self.file.remove(rel)
|
for rel in self.settings["opening"].HasFillings:
|
||||||
|
self.file.remove(rel)
|
||||||
ifcopenshell.api.run("root.remove_product", self.file, product=self.settings["opening"])
|
ifcopenshell.api.run("root.remove_product", self.file, product=self.settings["opening"])
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ class TestCopyClass(test.bootstrap.IFC4):
|
|||||||
assert new.RepresentationMaps is None
|
assert new.RepresentationMaps is None
|
||||||
|
|
||||||
def test_copying_an_element_with_an_opening(self):
|
def test_copying_an_element_with_an_opening(self):
|
||||||
|
# IfcOpeningElement opening
|
||||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||||
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||||
ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
|
ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=wall)
|
||||||
@@ -129,6 +130,16 @@ class TestCopyClass(test.bootstrap.IFC4):
|
|||||||
assert new.HasOpenings[0].RelatedOpeningElement != opening
|
assert new.HasOpenings[0].RelatedOpeningElement != opening
|
||||||
assert new.HasOpenings[0].RelatedOpeningElement.is_a("IfcOpeningElement")
|
assert new.HasOpenings[0].RelatedOpeningElement.is_a("IfcOpeningElement")
|
||||||
|
|
||||||
|
# IfcVoidingFeature opening
|
||||||
|
plate = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcPlate")
|
||||||
|
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcVoidingFeature")
|
||||||
|
ifcopenshell.api.run("void.add_opening", self.file, opening=opening, element=plate)
|
||||||
|
new = ifcopenshell.api.run("root.copy_class", self.file, product=plate)
|
||||||
|
assert plate.HasOpenings[0] != new.HasOpenings[0]
|
||||||
|
assert plate.HasOpenings[0].RelatedOpeningElement == opening
|
||||||
|
assert new.HasOpenings[0].RelatedOpeningElement != opening
|
||||||
|
assert new.HasOpenings[0].RelatedOpeningElement.is_a("IfcVoidingFeature")
|
||||||
|
|
||||||
def test_copying_an_element_with_a_filled_opening_should_not_copy_the_opening_nor_fill(self):
|
def test_copying_an_element_with_a_filled_opening_should_not_copy_the_opening_nor_fill(self):
|
||||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||||
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
opening = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcOpeningElement")
|
||||||
|
|||||||
Reference in New Issue
Block a user