mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
typing
This commit is contained in:
@@ -27,9 +27,7 @@ def remove_organisation(file: ifcopenshell.file, organisation: ifcopenshell.enti
|
||||
removed.
|
||||
|
||||
:param organisation: The IfcOrganization to remove
|
||||
:type organisation: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
@@ -39,31 +37,29 @@ def remove_organisation(file: ifcopenshell.file, organisation: ifcopenshell.enti
|
||||
identification="AWB", name="Architects Without Ballpens")
|
||||
ifcopenshell.api.owner.remove_organisation(model, organisation=organisation)
|
||||
"""
|
||||
settings = {"organisation": organisation}
|
||||
|
||||
for role in settings["organisation"].Roles or []:
|
||||
for role in organisation.Roles or []:
|
||||
if len(file.get_inverse(role)) == 1:
|
||||
ifcopenshell.api.owner.remove_role(file, role=role)
|
||||
for address in settings["organisation"].Addresses or []:
|
||||
for address in organisation.Addresses or []:
|
||||
if len(file.get_inverse(address)) == 1:
|
||||
ifcopenshell.api.owner.remove_address(file, address=address)
|
||||
for inverse in file.get_inverse(settings["organisation"]):
|
||||
for inverse in file.get_inverse(organisation):
|
||||
if inverse.is_a("IfcOrganizationRelationship"):
|
||||
if inverse.RelatingOrganization == settings["organisation"]:
|
||||
if inverse.RelatingOrganization == organisation:
|
||||
file.remove(inverse)
|
||||
elif inverse.RelatedOrganizations == (settings["organisation"],):
|
||||
elif inverse.RelatedOrganizations == (organisation,):
|
||||
file.remove(inverse)
|
||||
elif inverse.is_a("IfcDocumentInformation"):
|
||||
if inverse.Editors == (settings["organisation"],):
|
||||
if inverse.Editors == (organisation,):
|
||||
inverse.Editors = None
|
||||
elif inverse.is_a("IfcPersonAndOrganization"):
|
||||
ifcopenshell.api.owner.remove_person_and_organisation(file, person_and_organisation=inverse)
|
||||
elif inverse.is_a("IfcActor"):
|
||||
ifcopenshell.api.root.remove_product(file, product=inverse)
|
||||
elif inverse.is_a("IfcResourceLevelRelationship") and not inverse.is_a("IfcOrganizationRelationship"):
|
||||
if inverse.RelatedResourceObjects == (settings["organisation"],):
|
||||
if inverse.RelatedResourceObjects == (organisation,):
|
||||
file.remove(inverse)
|
||||
elif inverse.is_a("IfcApplication"):
|
||||
ifcopenshell.api.owner.remove_application(file, application=inverse)
|
||||
|
||||
file.remove(settings["organisation"])
|
||||
file.remove(organisation)
|
||||
|
||||
@@ -29,9 +29,7 @@ def remove_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance)
|
||||
the only responsile person for them.
|
||||
|
||||
:param person: The IfcPerson to remove
|
||||
:type person: ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
@@ -41,31 +39,30 @@ def remove_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance)
|
||||
identification="bobthebuilder", family_name="Thebuilder", given_name="Bob")
|
||||
ifcopenshell.api.owner.remove_person(model, person=person)
|
||||
"""
|
||||
settings = {"person": person}
|
||||
|
||||
for role in settings["person"].Roles or []:
|
||||
for role in person.Roles or []:
|
||||
if len(file.get_inverse(role)) == 1:
|
||||
ifcopenshell.api.owner.remove_role(file, role=role)
|
||||
for address in settings["person"].Addresses or []:
|
||||
for address in person.Addresses or []:
|
||||
if len(file.get_inverse(address)) == 1:
|
||||
ifcopenshell.api.owner.remove_address(file, address=address)
|
||||
for inverse in file.get_inverse(settings["person"]):
|
||||
for inverse in file.get_inverse(person):
|
||||
if inverse.is_a("IfcWorkControl"):
|
||||
if inverse.Creators == (settings["person"],):
|
||||
if inverse.Creators == (person,):
|
||||
inverse.Creators = None
|
||||
elif inverse.is_a("IfcInventory"):
|
||||
if inverse.ResponsiblePersons == (settings["person"],):
|
||||
if inverse.ResponsiblePersons == (person,):
|
||||
# in IFC2X3 ResponsiblePersons is not optional and without it IfcInventory is not valid
|
||||
if file.schema == "IFC2X3":
|
||||
ifcopenshell.api.root.remove_product(file, product=inverse)
|
||||
elif inverse.is_a("IfcDocumentInformation"):
|
||||
if inverse.Editors == (settings["person"],):
|
||||
if inverse.Editors == (person,):
|
||||
inverse.Editors = None
|
||||
elif inverse.is_a("IfcPersonAndOrganization"):
|
||||
ifcopenshell.api.owner.remove_person_and_organisation(file, person_and_organisation=inverse)
|
||||
elif inverse.is_a("IfcActor"):
|
||||
ifcopenshell.api.root.remove_product(file, product=inverse)
|
||||
elif inverse.is_a("IfcResourceLevelRelationship"):
|
||||
if inverse.RelatedResourceObjects == (settings["person"],):
|
||||
if inverse.RelatedResourceObjects == (person,):
|
||||
file.remove(inverse)
|
||||
file.remove(settings["person"])
|
||||
file.remove(person)
|
||||
|
||||
Reference in New Issue
Block a user