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
@@ -20,34 +20,31 @@ import ifcopenshell
import ifcopenshell.util.element
class Usecase:
def __init__(self, file: ifcopenshell.file, reference: ifcopenshell.entity_instance):
"""Removes a library reference
def remove_reference(file: ifcopenshell.file, reference: ifcopenshell.entity_instance) -> None:
"""Removes a library reference
Any products which have relationships to this reference will not be
removed.
Any products which have relationships to this reference will not be
removed.
:param reference: The IfcLibraryReference entity you want to remove
:type reference: ifcopenshell.entity_instance
:return: None
:rtype: None
:param reference: The IfcLibraryReference entity you want to remove
:type reference: ifcopenshell.entity_instance
:return: None
:rtype: None
Example:
Example:
.. code:: python
.. code:: python
library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
reference = ifcopenshell.api.run("library.add_reference", model, library=library)
# Let's change our mind and remove it.
ifcopenshell.api.run("library.remove_reference", model, reference=reference)
"""
self.file = file
self.settings = {"reference": reference}
library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
reference = ifcopenshell.api.run("library.add_reference", model, library=library)
# Let's change our mind and remove it.
ifcopenshell.api.run("library.remove_reference", model, reference=reference)
"""
settings = {"reference": reference}
def execute(self) -> None:
for rel in self.settings["reference"].LibraryRefForObjects:
history = rel.OwnerHistory
self.file.remove(rel)
if history:
ifcopenshell.util.element.remove_deep2(self.file, history)
self.file.remove(self.settings["reference"])
for rel in settings["reference"].LibraryRefForObjects:
history = rel.OwnerHistory
file.remove(rel)
if history:
ifcopenshell.util.element.remove_deep2(file, history)
file.remove(settings["reference"])