mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
Generate functions for all API usecases for better static code features. See #2693.
This commit is contained in:
@@ -20,44 +20,41 @@ import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file: ifcopenshell.entity_instance, opening: ifcopenshell.entity_instance):
|
||||
"""Remove an opening
|
||||
def remove_opening(file: ifcopenshell.entity_instance, opening: ifcopenshell.entity_instance) -> None:
|
||||
"""Remove an opening
|
||||
|
||||
Fillings are retained as orphans. Voided elements remain. Openings
|
||||
cannot exist by themselves, so not only is the opening relationship
|
||||
removed, the opening is also removed.
|
||||
Fillings are retained as orphans. Voided elements remain. Openings
|
||||
cannot exist by themselves, so not only is the opening relationship
|
||||
removed, the opening is also removed.
|
||||
|
||||
:param opening: The IfcOpeningElement to remove.
|
||||
:type opening: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
:param opening: The IfcOpeningElement to remove.
|
||||
:type opening: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
Example:
|
||||
|
||||
.. code:: python
|
||||
.. code:: python
|
||||
|
||||
# Create an oprhaned opening. Note that an orphaned opening is
|
||||
# invalid, as an opening can only exist when voiding another
|
||||
# element.
|
||||
opening = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcOpeningElement")
|
||||
# Create an oprhaned opening. Note that an orphaned opening is
|
||||
# invalid, as an opening can only exist when voiding another
|
||||
# element.
|
||||
opening = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcOpeningElement")
|
||||
|
||||
# Remove it. This brings us back to a valid model.
|
||||
ifcopenshell.api.run("void.remove_opening", model, opening=opening)
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"opening": opening}
|
||||
# Remove it. This brings us back to a valid model.
|
||||
ifcopenshell.api.run("void.remove_opening", model, opening=opening)
|
||||
"""
|
||||
settings = {"opening": opening}
|
||||
|
||||
def execute(self) -> None:
|
||||
for rel in self.settings["opening"].VoidsElements:
|
||||
for rel in settings["opening"].VoidsElements:
|
||||
history = rel.OwnerHistory
|
||||
file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
if settings["opening"].is_a("IfcOpeningElement"):
|
||||
for rel in settings["opening"].HasFillings:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
if self.settings["opening"].is_a("IfcOpeningElement"):
|
||||
for rel in self.settings["opening"].HasFillings:
|
||||
history = rel.OwnerHistory
|
||||
self.file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(self.file, history)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=self.settings["opening"])
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
ifcopenshell.api.run("root.remove_product", file, product=settings["opening"])
|
||||
|
||||
Reference in New Issue
Block a user