This commit is contained in:
Andrej730
2024-04-12 10:42:15 +05:00
parent e56aa45a82
commit 59b496d4b5
10 changed files with 31 additions and 16 deletions
@@ -16,9 +16,11 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
class Usecase:
def __init__(self, file, library=None):
def __init__(self, file: ifcopenshell.file, library: ifcopenshell.entity_instance):
"""Adds a new reference to a library
A library represents an external data source, such as a database,
@@ -54,7 +56,7 @@ class Usecase:
"library": library,
}
def execute(self):
def execute(self) -> ifcopenshell.entity_instance:
if self.file.schema == "IFC2X3":
reference = self.file.createIfcLibraryReference()
references = list(self.settings["library"].LibraryReference or [])
@@ -21,7 +21,7 @@ import ifcopenshell.util.element
class Usecase:
def __init__(self, file, reference=None):
def __init__(self, file: ifcopenshell.file, reference: ifcopenshell.entity_instance):
"""Removes a library reference
Any products which have relationships to this reference will not be
@@ -44,7 +44,7 @@ class Usecase:
self.file = file
self.settings = {"reference": reference}
def execute(self):
def execute(self) -> None:
for rel in self.settings["reference"].LibraryRefForObjects:
history = rel.OwnerHistory
self.file.remove(rel)