mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Generate functions for all API usecases for better static code features. See #2693.
This commit is contained in:
@@ -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"])
|
||||
|
||||
Reference in New Issue
Block a user