library.remove_library, remove_reference to support ifc2x3

This commit is contained in:
Andrej730
2024-05-13 17:44:19 +05:00
parent f2696d5352
commit 3665dda87c
2 changed files with 25 additions and 13 deletions
@@ -40,11 +40,14 @@ def remove_reference(file: ifcopenshell.file, reference: ifcopenshell.entity_ins
# Let's change our mind and remove it.
ifcopenshell.api.run("library.remove_reference", model, reference=reference)
"""
settings = {"reference": reference}
if file.schema != "IFC2X3":
rels = reference.LibraryRefForObjects
else:
rels = [rel for rel in file.by_type("IfcRelAssociatesLibrary") if rel.RelatingLibrary == reference]
for rel in settings["reference"].LibraryRefForObjects:
for rel in rels:
history = rel.OwnerHistory
file.remove(rel)
if history:
ifcopenshell.util.element.remove_deep2(file, history)
file.remove(settings["reference"])
file.remove(reference)