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,35 +20,32 @@ import ifcopenshell
import ifcopenshell.util.element
class Usecase:
def __init__(self, file, library=None):
"""Removes a library
def remove_library(file, library=None) -> None:
"""Removes a library
All references along with their relationships will also be removed. Any
products which have relationships to this library will not be removed.
All references along with their relationships will also be removed. Any
products which have relationships to this library will not be removed.
:param library: The IfcLibraryInformation entity you want to remove
:type library: ifcopenshell.entity_instance
:return: None
:rtype: None
:param library: The IfcLibraryInformation entity you want to remove
:type library: ifcopenshell.entity_instance
:return: None
:rtype: None
Example:
Example:
.. code:: python
.. code:: python
library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
ifcopenshell.api.run("library.remove_library", model, library=library)
"""
self.file = file
self.settings = {"library": library}
library = ifcopenshell.api.run("library.add_library", model, name="Brickschema")
ifcopenshell.api.run("library.remove_library", model, library=library)
"""
settings = {"library": library}
def execute(self):
for reference in set(self.settings["library"].HasLibraryReferences or []):
self.file.remove(reference)
self.file.remove(self.settings["library"])
for rel in self.file.by_type("IfcRelAssociatesLibrary"):
if not rel.RelatingLibrary:
history = rel.OwnerHistory
self.file.remove(rel)
if history:
ifcopenshell.util.element.remove_deep2(self.file, history)
for reference in set(settings["library"].HasLibraryReferences or []):
file.remove(reference)
file.remove(settings["library"])
for rel in file.by_type("IfcRelAssociatesLibrary"):
if not rel.RelatingLibrary:
history = rel.OwnerHistory
file.remove(rel)
if history:
ifcopenshell.util.element.remove_deep2(file, history)