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