mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
fix removing references in ifc2x3 #4636
This commit is contained in:
@@ -38,11 +38,15 @@ def remove_reference(file: ifcopenshell.file, reference: ifcopenshell.entity_ins
|
||||
reference = ifcopenshell.api.run("document.add_reference", model, information=document)
|
||||
ifcopenshell.api.run("document.remove_reference", model, reference=reference)
|
||||
"""
|
||||
settings = {"reference": reference}
|
||||
|
||||
for rel in settings["reference"].DocumentRefForObjects or []:
|
||||
if file.schema == "IFC2X3":
|
||||
rels = [r for r in file.get_inverse(reference) if r.is_a("IfcRelAssociatesDocument")]
|
||||
else:
|
||||
rels = reference.DocumentRefForObjects
|
||||
|
||||
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)
|
||||
|
||||
@@ -41,3 +41,7 @@ class TestRemoveReference(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcDocumentReference")) == 0
|
||||
assert len(self.file.by_type("IfcDocumentInformation")) == 1
|
||||
assert len(self.file.by_type("IfcRelAssociatesDocument")) == 1
|
||||
|
||||
|
||||
class TestRemoveReferenceIFC2X3(test.bootstrap.IFC2X3, TestRemoveReference):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user