Generate functions for all API usecases for better static code features. See #2693.

This commit is contained in:
Dion Moult
2024-05-06 14:35:39 +10:00
parent 10f894e2ea
commit d11ec67129
330 changed files with 13283 additions and 13751 deletions
@@ -22,45 +22,42 @@ import ifcopenshell.api
import ifcopenshell.util.element
class Usecase:
def __init__(self, file, information=None):
"""Removes a document information
def remove_information(file, information=None) -> None:
"""Removes a document information
All references and associations are also removed.
All references and associations are also removed.
:param information: The IfcDocumentInformation to remove
:type information: ifcopenshell.entity_instance
:return: None
:rtype: None
:param information: The IfcDocumentInformation to remove
:type information: ifcopenshell.entity_instance
:return: None
:rtype: None
Example:
Example:
.. code:: python
.. code:: python
# Add a document
document = ifcopenshell.api.run("document.add_information", model)
# ... and remove it!
ifcopenshell.api.run("document.remove_information", model, information=document)
"""
self.file = file
self.settings = {"information": information}
# Add a document
document = ifcopenshell.api.run("document.add_information", model)
# ... and remove it!
ifcopenshell.api.run("document.remove_information", model, information=document)
"""
settings = {"information": information}
def execute(self):
for reference in self.settings["information"].HasDocumentReferences or []:
ifcopenshell.api.run("document.remove_reference", self.file, reference=reference)
for reference in settings["information"].HasDocumentReferences or []:
ifcopenshell.api.run("document.remove_reference", file, reference=reference)
for rel in self.settings["information"].IsPointer or []:
for information in rel.RelatedDocuments:
ifcopenshell.api.run("document.remove_information", self.file, information=information)
for rel in settings["information"].IsPointer or []:
for information in rel.RelatedDocuments:
ifcopenshell.api.run("document.remove_information", file, information=information)
for rel in self.settings["information"].IsPointedTo or []:
if rel.RelatedDocuments == (self.settings["information"],):
# This relationship is non-rooted
self.file.remove(rel)
for rel in settings["information"].IsPointedTo or []:
if rel.RelatedDocuments == (settings["information"],):
# This relationship is non-rooted
file.remove(rel)
for rel in self.settings["information"].DocumentInfoForObjects or []:
history = rel.OwnerHistory
self.file.remove(rel)
if history:
ifcopenshell.util.element.remove_deep2(self.file, history)
self.file.remove(self.settings["information"])
for rel in settings["information"].DocumentInfoForObjects or []:
history = rel.OwnerHistory
file.remove(rel)
if history:
ifcopenshell.util.element.remove_deep2(file, history)
file.remove(settings["information"])