You can now add and remove users for ownership history

This commit is contained in:
Dion Moult
2021-10-01 17:32:58 +10:00
parent fe1e30702a
commit 4697e063af
23 changed files with 336 additions and 27 deletions
@@ -1,9 +1,9 @@
class Usecase:
def __init__(self, file, **settings):
self.file = file
self.settings = {"actor": None}
self.settings = {"person": None, "organisation": None}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
self.file.remove(self.settings["actor"])
return self.file.createIfcPersonAndOrganization(self.settings["person"], self.settings["organisation"])
@@ -27,7 +27,7 @@ class Usecase:
elif inverse.is_a("IfcPersonAndOrganization"):
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=inverse)
elif inverse.is_a("IfcActor"):
ifcopenshell.api.run("owner.remove_actor", self.file, actor=inverse)
ifcopenshell.api.run("root.remove_product", self.file, product=inverse)
elif inverse.is_a("IfcResourceLevelRelationship") and not inverse.is_a("IfcOrganizationRelationship"):
if inverse.RelatedResourceObjects == (self.settings["organisation"],):
self.file.remove(inverse)
@@ -28,7 +28,7 @@ class Usecase:
elif inverse.is_a("IfcPersonAndOrganization"):
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=inverse)
elif inverse.is_a("IfcActor"):
ifcopenshell.api.run("owner.remove_actor", self.file, actor=inverse)
ifcopenshell.api.run("root.remove_product", self.file, product=inverse)
elif inverse.is_a("IfcResourceLevelRelationship"):
if inverse.RelatedResourceObjects == (self.settings["person"],):
self.file.remove(inverse)
@@ -1,3 +1,6 @@
import ifcopenshell.api
class Usecase:
def __init__(self, file, **settings):
self.file = file
@@ -6,4 +9,15 @@ class Usecase:
self.settings[key] = value
def execute(self):
for inverse in self.file.get_inverse(self.settings["person_and_organisation"]):
if inverse.is_a("IfcDocumentInformation"):
if inverse.Editors == (self.settings["person_and_organisation"],):
inverse.Editors = None
elif inverse.is_a("IfcActor"):
ifcopenshell.api.run("root.remove_product", self.file, product=inverse)
elif inverse.is_a("IfcResourceLevelRelationship"):
if inverse.RelatedResourceObjects == (self.settings["person_and_organisation"],):
self.file.remove(inverse)
elif inverse.is_a("IfcOwnerHistory"):
self.file.remove(inverse)
self.file.remove(self.settings["person_and_organisation"])