mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
from typing import Literal
|
||||
|
||||
|
||||
@@ -60,15 +60,15 @@ def add_actor(
|
||||
.. code:: python
|
||||
|
||||
# Setup an organisation with a single role
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="AWB", name="Architects Without Ballpens")
|
||||
role = ifcopenshell.api.run("owner.add_role", model, assigned_object=organisation, role="ARCHITECT")
|
||||
role = ifcopenshell.api.owner.add_role(model, assigned_object=organisation, role="ARCHITECT")
|
||||
|
||||
# Assign that organisation to a newly created actor
|
||||
actor = ifcopenshell.api.run("owner.add_actor", model, actor=organisation)
|
||||
actor = ifcopenshell.api.owner.add_actor(model, actor=organisation)
|
||||
"""
|
||||
settings = {"actor": actor, "ifc_class": ifc_class or "IfcActor"}
|
||||
|
||||
actor = ifcopenshell.api.run("root.create_entity", file, ifc_class=settings["ifc_class"])
|
||||
actor = ifcopenshell.api.root.create_entity(file, ifc_class=settings["ifc_class"])
|
||||
actor.TheActor = settings["actor"]
|
||||
return actor
|
||||
|
||||
@@ -50,19 +50,19 @@ def add_address(
|
||||
|
||||
.. code:: python
|
||||
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model)
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model)
|
||||
|
||||
# A snail mail address
|
||||
postal = ifcopenshell.api.run("owner.add_address", model,
|
||||
postal = ifcopenshell.api.owner.add_address(model,
|
||||
assigned_object=organisation, ifc_class="IfcPostalAddress")
|
||||
ifcopenshell.api.run("owner.edit_address", model, address=postal,
|
||||
ifcopenshell.api.owner.edit_address(model, address=postal,
|
||||
attributes={"Purpose": "OFFICE", "AddressLines": ["42 Wallaby Way"],
|
||||
"Town": "Sydney", "Region": "NSW", "PostalCode": "2000"})
|
||||
|
||||
# A phone or internet address
|
||||
telecom = ifcopenshell.api.run("owner.add_address", model,
|
||||
telecom = ifcopenshell.api.owner.add_address(model,
|
||||
assigned_object=organisation, ifc_class="IfcTelecomAddress")
|
||||
ifcopenshell.api.run("owner.edit_address", model, address=telecom,
|
||||
ifcopenshell.api.owner.edit_address(model, address=telecom,
|
||||
attributes={"Purpose": "OFFICE", "TelephoneNumbers": ["+61432466949"],
|
||||
"ElectronicMailAddresses": ["bobthebuilder@example.com"],
|
||||
"WWWHomePageURL": "https://thinkmoult.com"})
|
||||
|
||||
@@ -54,7 +54,7 @@ def add_application(
|
||||
|
||||
.. code:: python
|
||||
|
||||
application = ifcopenshell.api.run("owner.add_application", model)
|
||||
application = ifcopenshell.api.owner.add_application(model)
|
||||
"""
|
||||
usecase = Usecase()
|
||||
usecase.file = file
|
||||
|
||||
@@ -41,7 +41,7 @@ def add_organisation(
|
||||
|
||||
.. code:: python
|
||||
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="AWB", name="Architects Without Ballpens")
|
||||
"""
|
||||
settings = {"identification": identification, "name": name}
|
||||
|
||||
@@ -43,7 +43,7 @@ def add_person(
|
||||
|
||||
.. code:: python
|
||||
|
||||
ifcopenshell.api.run("owner.add_person", model,
|
||||
ifcopenshell.api.owner.add_person(model,
|
||||
identification="bobthebuilder", family_name="Thebuilder", given_name="Bob")
|
||||
"""
|
||||
settings = {
|
||||
|
||||
@@ -40,12 +40,12 @@ def add_person_and_organisation(
|
||||
|
||||
.. code:: python
|
||||
|
||||
person = ifcopenshell.api.run("owner.add_person", model,
|
||||
person = ifcopenshell.api.owner.add_person(model,
|
||||
identification="lecorbycorbycorb", family_name="Curbosiar", given_name="Le")
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="AWB", name="Architects Without Ballpens")
|
||||
|
||||
ifcopenshell.api.run("owner.add_person_and_organisation", model,
|
||||
ifcopenshell.api.owner.add_person_and_organisation(model,
|
||||
person=person, organisation=organisation)
|
||||
"""
|
||||
settings = {"person": person, "organisation": organisation}
|
||||
|
||||
@@ -42,9 +42,9 @@ def add_role(file: ifcopenshell.file, assigned_object: ifcopenshell.entity_insta
|
||||
|
||||
.. code:: python
|
||||
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="AWB", name="Architects Without Ballpens")
|
||||
ifcopenshell.api.run("owner.add_role", model, assigned_object=organisation, role="ARCHITECT")
|
||||
ifcopenshell.api.owner.add_role(model, assigned_object=organisation, role="ARCHITECT")
|
||||
"""
|
||||
settings = {"assigned_object": assigned_object, "role": role}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
@@ -54,24 +54,24 @@ def assign_actor(
|
||||
.. code:: python
|
||||
|
||||
# We need to procure and install 2 of this particular pump type in our facility.
|
||||
pump_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcPumpType")
|
||||
pump_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcPumpType")
|
||||
|
||||
# Define who the manufacturer is
|
||||
manufacturer = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
manufacturer = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="PWP", name="Pumps With Power")
|
||||
ifcopenshell.api.run("owner.add_role", model, assigned_object=manufacturer, role="MANUFACTURER")
|
||||
ifcopenshell.api.owner.add_role(model, assigned_object=manufacturer, role="MANUFACTURER")
|
||||
|
||||
# To help our facility manager, it's nice to provide contact details
|
||||
# of the manufacturer so they know how to call when the pump breaks.
|
||||
telecom = ifcopenshell.api.run("owner.add_address", model,
|
||||
telecom = ifcopenshell.api.owner.add_address(model,
|
||||
assigned_object=organisation, ifc_class="IfcTelecomAddress")
|
||||
ifcopenshell.api.run("owner.edit_address", model, address=telecom,
|
||||
ifcopenshell.api.owner.edit_address(model, address=telecom,
|
||||
attributes={"Purpose": "OFFICE", "TelephoneNumbers": ["+61432466949"],
|
||||
"ElectronicMailAddresses": ["contact@example.com"],
|
||||
"WWWHomePageURL": "https://example.com"})
|
||||
|
||||
# Make the manufacturer responsible for that pump type.
|
||||
ifcopenshell.api.run("owner.assign_actor", model,
|
||||
ifcopenshell.api.owner.assign_actor(model,
|
||||
relating_actor=manufacturer, related_object=pump_type)
|
||||
"""
|
||||
settings = {
|
||||
@@ -93,13 +93,13 @@ def assign_actor(
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.append(settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
|
||||
else:
|
||||
rel = file.create_entity(
|
||||
"IfcRelAssignsToActor",
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
|
||||
"RelatedObjects": [settings["related_object"]],
|
||||
"RelatingActor": settings["relating_actor"],
|
||||
}
|
||||
|
||||
@@ -71,16 +71,16 @@ def create_owner_history(file: ifcopenshell.file) -> Union[ifcopenshell.entity_i
|
||||
# its own fully branded application. In this case, let's use the
|
||||
# default application which is prepopulated with "IfcOpenShell" as
|
||||
# the name and version.
|
||||
application = ifcopenshell.api.run("owner.add_application", model)
|
||||
application = ifcopenshell.api.owner.add_application(model)
|
||||
|
||||
# Let's imagine we run this as an automated QA process in an
|
||||
# architectural firm. However, the results must be signed off by the
|
||||
# registered architect who is liable for the project.
|
||||
person = ifcopenshell.api.run("owner.add_person", model,
|
||||
person = ifcopenshell.api.owner.add_person(model,
|
||||
identification="LPARTEE", family_name="Partee", given_name="Leeable")
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="AWB", name="Architects Without Ballpens")
|
||||
user = ifcopenshell.api.run("owner.add_person_and_organisation", model,
|
||||
user = ifcopenshell.api.owner.add_person_and_organisation(model,
|
||||
person=person, organisation=organisation)
|
||||
|
||||
# Let's configure our owner settings to hardcode always returning
|
||||
@@ -94,8 +94,8 @@ def create_owner_history(file: ifcopenshell.file) -> Union[ifcopenshell.entity_i
|
||||
# create_owner_history at all. This is already automatically handled
|
||||
# by the API when necessary. Under the hood, the API is actually
|
||||
# running this code on the IfcSpace element:
|
||||
# element.OwnerHistory = ifcopenshell.api.run("owner.create_owner_history", model)
|
||||
space = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSpace")
|
||||
# element.OwnerHistory = ifcopenshell.api.owner.create_owner_history(model)
|
||||
space = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSpace")
|
||||
"""
|
||||
settings = {}
|
||||
|
||||
|
||||
@@ -37,16 +37,16 @@ def edit_actor(file: ifcopenshell.file, actor: ifcopenshell.entity_instance, att
|
||||
.. code:: python
|
||||
|
||||
# Setup an organisation with a single role
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="AWB", name="Architects Without Ballpens")
|
||||
role = ifcopenshell.api.run("owner.add_role", model, assigned_object=organisation)
|
||||
ifcopenshell.api.run("owner.edit_role", model, role=role, attributes={"Role": "ARCHITECT"})
|
||||
role = ifcopenshell.api.owner.add_role(model, assigned_object=organisation)
|
||||
ifcopenshell.api.owner.edit_role(model, role=role, attributes={"Role": "ARCHITECT"})
|
||||
|
||||
# Assign that organisation to a newly created actor
|
||||
actor = ifcopenshell.api.run("owner.add_actor", model, actor=organisation)
|
||||
actor = ifcopenshell.api.owner.add_actor(model, actor=organisation)
|
||||
|
||||
# Edit the description of the attribute.
|
||||
ifcopenshell.api.run("actor.edit_actor", model,
|
||||
ifcopenshell.api.actor.edit_actor(model,
|
||||
actor=actor, attributes={"Description": "Responsible for buildings A, B, and C."})
|
||||
"""
|
||||
settings = {"actor": actor, "attributes": attributes}
|
||||
|
||||
@@ -37,16 +37,16 @@ def edit_address(file: ifcopenshell.file, address: ifcopenshell.entity_instance,
|
||||
.. code:: python
|
||||
|
||||
# A snail mail address
|
||||
postal = ifcopenshell.api.run("owner.add_address", model,
|
||||
postal = ifcopenshell.api.owner.add_address(model,
|
||||
assigned_object=organisation, ifc_class="IfcPostalAddress")
|
||||
ifcopenshell.api.run("owner.edit_address", model, address=postal,
|
||||
ifcopenshell.api.owner.edit_address(model, address=postal,
|
||||
attributes={"Purpose": "OFFICE", "AddressLines": ["42 Wallaby Way"],
|
||||
"Town": "Sydney", "Region": "NSW", "PostalCode": "2000"})
|
||||
|
||||
# A phone or internet address
|
||||
telecom = ifcopenshell.api.run("owner.add_address", model,
|
||||
telecom = ifcopenshell.api.owner.add_address(model,
|
||||
assigned_object=organisation, ifc_class="IfcTelecomAddress")
|
||||
ifcopenshell.api.run("owner.edit_address", model, address=telecom,
|
||||
ifcopenshell.api.owner.edit_address(model, address=telecom,
|
||||
attributes={"Purpose": "OFFICE", "TelephoneNumbers": ["+61432466949"],
|
||||
"ElectronicMailAddresses": ["bobthebuilder@example.com"],
|
||||
"WWWHomePageURL": "https://thinkmoult.com"})
|
||||
|
||||
@@ -36,9 +36,9 @@ def edit_organisation(file: ifcopenshell.file, organisation: ifcopenshell.entity
|
||||
|
||||
.. code:: python
|
||||
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="AWB", name="Architects With Ballpens")
|
||||
ifcopenshell.api.run("owner.edit_organisation", model, organisation=organisation,
|
||||
ifcopenshell.api.owner.edit_organisation(model, organisation=organisation,
|
||||
attributes={"name": "Architects Without Ballpens"})
|
||||
"""
|
||||
settings = {"organisation": organisation, "attributes": attributes}
|
||||
|
||||
@@ -36,9 +36,9 @@ def edit_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance, a
|
||||
|
||||
.. code:: python
|
||||
|
||||
person = ifcopenshell.api.run("owner.add_person", model,
|
||||
person = ifcopenshell.api.owner.add_person(model,
|
||||
identification="bobthebuilder", family_name="Thebuilder", given_name="Bob")
|
||||
ifcopenshell.api.run("owner.edit_person", model, person=person,
|
||||
ifcopenshell.api.owner.edit_person(model, person=person,
|
||||
attributes={"MiddleNames": ["The"], "FamilyName": "Builder"})
|
||||
"""
|
||||
settings = {"person": person, "attributes": attributes}
|
||||
|
||||
@@ -36,14 +36,14 @@ def edit_role(file: ifcopenshell.file, role: ifcopenshell.entity_instance, attri
|
||||
|
||||
.. code:: python
|
||||
|
||||
person = ifcopenshell.api.run("owner.add_person", model,
|
||||
person = ifcopenshell.api.owner.add_person(model,
|
||||
identification="bobthebuilder", family_name="Thebuilder", given_name="Bob")
|
||||
|
||||
# By default, the role is an architect
|
||||
role = ifcopenshell.api.run("owner.add_role", model, assigned_object=person)
|
||||
role = ifcopenshell.api.owner.add_role(model, assigned_object=person)
|
||||
|
||||
# But Bob is not an architect
|
||||
ifcopenshell.api.run("owner.edit_role", model, role=role, attributes={"Role": "CONSTRUCTIONMANAGER"})
|
||||
ifcopenshell.api.owner.edit_role(model, role=role, attributes={"Role": "CONSTRUCTIONMANAGER"})
|
||||
"""
|
||||
settings = {"role": role, "attributes": attributes}
|
||||
|
||||
|
||||
@@ -33,16 +33,16 @@ def remove_actor(file: ifcopenshell.file, actor: ifcopenshell.entity_instance) -
|
||||
.. code:: python
|
||||
|
||||
# Setup an organisation with a single role
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="AWB", name="Architects Without Ballpens")
|
||||
role = ifcopenshell.api.run("owner.add_role", model, assigned_object=organisation)
|
||||
ifcopenshell.api.run("owner.edit_role", model, role=role, attributes={"Role": "ARCHITECT"})
|
||||
role = ifcopenshell.api.owner.add_role(model, assigned_object=organisation)
|
||||
ifcopenshell.api.owner.edit_role(model, role=role, attributes={"Role": "ARCHITECT"})
|
||||
|
||||
# Assign that organisation to a newly created actor
|
||||
actor = ifcopenshell.api.run("owner.add_actor", model, actor=organisation)
|
||||
actor = ifcopenshell.api.owner.add_actor(model, actor=organisation)
|
||||
|
||||
# Actually we need ballpens on this project
|
||||
ifcopenshell.api.run("owner.remove_actor", model, actor=actor)
|
||||
ifcopenshell.api.owner.remove_actor(model, actor=actor)
|
||||
"""
|
||||
settings = {"actor": actor}
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ def remove_address(file: ifcopenshell.file, address: ifcopenshell.entity_instanc
|
||||
|
||||
.. code:: python
|
||||
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model)
|
||||
address = ifcopenshell.api.run("owner.add_address", model,
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model)
|
||||
address = ifcopenshell.api.owner.add_address(model,
|
||||
assigned_object=organisation, ifc_class="IfcPostalAddress")
|
||||
|
||||
# Change our mind and delete it
|
||||
ifcopenshell.api.run("owner.remove_address", model, address=address)
|
||||
ifcopenshell.api.owner.remove_address(model, address=address)
|
||||
"""
|
||||
settings = {"address": address}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ def remove_application(file: ifcopenshell.file, application: ifcopenshell.entity
|
||||
|
||||
.. code:: python
|
||||
|
||||
application = ifcopenshell.api.run("owner.add_application", model)
|
||||
ifcopenshell.api.run("owner.remove_address", model, application=application)
|
||||
application = ifcopenshell.api.owner.add_application(model)
|
||||
ifcopenshell.api.owner.remove_address(model, application=application)
|
||||
"""
|
||||
settings = {"application": application}
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
# 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.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
def remove_organisation(file: ifcopenshell.file, organisation: ifcopenshell.entity_instance) -> None:
|
||||
@@ -34,18 +35,18 @@ def remove_organisation(file: ifcopenshell.file, organisation: ifcopenshell.enti
|
||||
|
||||
.. code:: python
|
||||
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="AWB", name="Architects Without Ballpens")
|
||||
ifcopenshell.api.run("owner.remove_organisation", model, organisation=organisation)
|
||||
ifcopenshell.api.owner.remove_organisation(model, organisation=organisation)
|
||||
"""
|
||||
settings = {"organisation": organisation}
|
||||
|
||||
for role in settings["organisation"].Roles or []:
|
||||
if len(file.get_inverse(role)) == 1:
|
||||
ifcopenshell.api.run("owner.remove_role", file, role=role)
|
||||
ifcopenshell.api.owner.remove_role(file, role=role)
|
||||
for address in settings["organisation"].Addresses or []:
|
||||
if len(file.get_inverse(address)) == 1:
|
||||
ifcopenshell.api.run("owner.remove_address", file, address=address)
|
||||
ifcopenshell.api.owner.remove_address(file, address=address)
|
||||
for inverse in file.get_inverse(settings["organisation"]):
|
||||
if inverse.is_a("IfcOrganizationRelationship"):
|
||||
if inverse.RelatingOrganization == settings["organisation"]:
|
||||
@@ -56,13 +57,13 @@ def remove_organisation(file: ifcopenshell.file, organisation: ifcopenshell.enti
|
||||
if inverse.Editors == (settings["organisation"],):
|
||||
inverse.Editors = None
|
||||
elif inverse.is_a("IfcPersonAndOrganization"):
|
||||
ifcopenshell.api.run("owner.remove_person_and_organisation", file, person_and_organisation=inverse)
|
||||
ifcopenshell.api.owner.remove_person_and_organisation(file, person_and_organisation=inverse)
|
||||
elif inverse.is_a("IfcActor"):
|
||||
ifcopenshell.api.run("root.remove_product", file, product=inverse)
|
||||
ifcopenshell.api.root.remove_product(file, product=inverse)
|
||||
elif inverse.is_a("IfcResourceLevelRelationship") and not inverse.is_a("IfcOrganizationRelationship"):
|
||||
if inverse.RelatedResourceObjects == (settings["organisation"],):
|
||||
file.remove(inverse)
|
||||
elif inverse.is_a("IfcApplication"):
|
||||
ifcopenshell.api.run("owner.remove_application", file, application=inverse)
|
||||
ifcopenshell.api.owner.remove_application(file, application=inverse)
|
||||
|
||||
file.remove(settings["organisation"])
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
# 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.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.owner
|
||||
|
||||
|
||||
def remove_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance) -> None:
|
||||
@@ -36,18 +37,18 @@ def remove_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance)
|
||||
|
||||
.. code:: python
|
||||
|
||||
ifcopenshell.api.run("owner.add_person", model,
|
||||
ifcopenshell.api.owner.add_person(model,
|
||||
identification="bobthebuilder", family_name="Thebuilder", given_name="Bob")
|
||||
ifcopenshell.api.run("owner.remove_person", model, person=person)
|
||||
ifcopenshell.api.owner.remove_person(model, person=person)
|
||||
"""
|
||||
settings = {"person": person}
|
||||
|
||||
for role in settings["person"].Roles or []:
|
||||
if len(file.get_inverse(role)) == 1:
|
||||
ifcopenshell.api.run("owner.remove_role", file, role=role)
|
||||
ifcopenshell.api.owner.remove_role(file, role=role)
|
||||
for address in settings["person"].Addresses or []:
|
||||
if len(file.get_inverse(address)) == 1:
|
||||
ifcopenshell.api.run("owner.remove_address", file, address=address)
|
||||
ifcopenshell.api.owner.remove_address(file, address=address)
|
||||
for inverse in file.get_inverse(settings["person"]):
|
||||
if inverse.is_a("IfcWorkControl"):
|
||||
if inverse.Creators == (settings["person"],):
|
||||
@@ -56,14 +57,14 @@ def remove_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance)
|
||||
if inverse.ResponsiblePersons == (settings["person"],):
|
||||
# in IFC2X3 ResponsiblePersons is not optional and without it IfcInventory is not valid
|
||||
if file.schema == "IFC2X3":
|
||||
ifcopenshell.api.run("root.remove_product", file, product=inverse)
|
||||
ifcopenshell.api.root.remove_product(file, product=inverse)
|
||||
elif inverse.is_a("IfcDocumentInformation"):
|
||||
if inverse.Editors == (settings["person"],):
|
||||
inverse.Editors = None
|
||||
elif inverse.is_a("IfcPersonAndOrganization"):
|
||||
ifcopenshell.api.run("owner.remove_person_and_organisation", file, person_and_organisation=inverse)
|
||||
ifcopenshell.api.owner.remove_person_and_organisation(file, person_and_organisation=inverse)
|
||||
elif inverse.is_a("IfcActor"):
|
||||
ifcopenshell.api.run("root.remove_product", file, product=inverse)
|
||||
ifcopenshell.api.root.remove_product(file, product=inverse)
|
||||
elif inverse.is_a("IfcResourceLevelRelationship"):
|
||||
if inverse.RelatedResourceObjects == (settings["person"],):
|
||||
file.remove(inverse)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# 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.api
|
||||
import ifcopenshell.api.root
|
||||
|
||||
|
||||
def remove_person_and_organisation(
|
||||
@@ -36,15 +36,15 @@ def remove_person_and_organisation(
|
||||
|
||||
.. code:: python
|
||||
|
||||
person = ifcopenshell.api.run("owner.add_person", model,
|
||||
person = ifcopenshell.api.owner.add_person(model,
|
||||
identification="lecorbycorbycorb", family_name="Curbosiar", given_name="Le")
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="AWB", name="Architects Without Ballpens")
|
||||
|
||||
user = ifcopenshell.api.run("owner.add_person_and_organisation", model,
|
||||
user = ifcopenshell.api.owner.add_person_and_organisation(model,
|
||||
person=person, organisation=organisation)
|
||||
|
||||
ifcopenshell.api.run("owner.remove_person_and_organisation", model, person_and_organisation=user)
|
||||
ifcopenshell.api.owner.remove_person_and_organisation(model, person_and_organisation=user)
|
||||
"""
|
||||
settings = {"person_and_organisation": person_and_organisation}
|
||||
|
||||
@@ -53,7 +53,7 @@ def remove_person_and_organisation(
|
||||
if inverse.Editors == (settings["person_and_organisation"],):
|
||||
inverse.Editors = None
|
||||
elif inverse.is_a("IfcActor"):
|
||||
ifcopenshell.api.run("root.remove_product", file, product=inverse)
|
||||
ifcopenshell.api.root.remove_product(file, product=inverse)
|
||||
elif inverse.is_a("IfcResourceLevelRelationship"):
|
||||
if inverse.RelatedResourceObjects == (settings["person_and_organisation"],):
|
||||
file.remove(inverse)
|
||||
|
||||
@@ -33,12 +33,12 @@ def remove_role(file: ifcopenshell.file, role: ifcopenshell.entity_instance) ->
|
||||
|
||||
.. code:: python
|
||||
|
||||
organisation = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
organisation = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="AWB", name="Architects Without Ballpens")
|
||||
role = ifcopenshell.api.run("owner.add_role", model, assigned_object=organisation, role="ARCHITECT")
|
||||
role = ifcopenshell.api.owner.add_role(model, assigned_object=organisation, role="ARCHITECT")
|
||||
|
||||
# After running this, the organisation will have no role again
|
||||
ifcopenshell.api.run("owner.remove_role", model, role=role)
|
||||
ifcopenshell.api.owner.remove_role(model, role=role)
|
||||
"""
|
||||
settings = {"role": role}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.owner
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -40,19 +40,19 @@ def unassign_actor(
|
||||
.. code:: python
|
||||
|
||||
# We need to procure and install 2 of this particular pump type in our facility.
|
||||
pump_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcPumpType")
|
||||
pump_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcPumpType")
|
||||
|
||||
# Define who the manufacturer is
|
||||
manufacturer = ifcopenshell.api.run("owner.add_organisation", model,
|
||||
manufacturer = ifcopenshell.api.owner.add_organisation(model,
|
||||
identification="PWP", name="Pumps With Power")
|
||||
ifcopenshell.api.run("owner.add_role", model, assigned_object=manufacturer, role="MANUFACTURER")
|
||||
ifcopenshell.api.owner.add_role(model, assigned_object=manufacturer, role="MANUFACTURER")
|
||||
|
||||
# Make the manufacturer responsible for that pump type.
|
||||
ifcopenshell.api.run("owner.assign_actor", model,
|
||||
ifcopenshell.api.owner.assign_actor(model,
|
||||
relating_actor=manufacturer, related_object=pump_type)
|
||||
|
||||
# Undo the assignment
|
||||
ifcopenshell.api.run("owner.unassign_actor", model,
|
||||
ifcopenshell.api.owner.unassign_actor(model,
|
||||
relating_actor=manufacturer, related_object=pump_type)
|
||||
"""
|
||||
settings = {
|
||||
@@ -72,4 +72,4 @@ def unassign_actor(
|
||||
related_objects = list(rel.RelatedObjects)
|
||||
related_objects.remove(settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
ifcopenshell.api.owner.update_owner_history(file, **{"element": rel})
|
||||
|
||||
@@ -51,13 +51,13 @@ def update_owner_history(
|
||||
# create_owner_history at all. This is already automatically handled
|
||||
# by the API when necessary. Under the hood, the API is actually
|
||||
# running this code on the IfcSpace element:
|
||||
# element.OwnerHistory = ifcopenshell.api.run("owner.create_owner_history", model)
|
||||
space = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcSpace")
|
||||
# element.OwnerHistory = ifcopenshell.api.owner.create_owner_history(model)
|
||||
space = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSpace")
|
||||
|
||||
# Any edits we make will have ownership tracking automatically
|
||||
# applied. There is no need to run any owner.update_owner_history
|
||||
# API calls either.
|
||||
ifcopenshell.api.run("attribute.edit_attributes", model, product=space, attributes={"Name": "Lobby"})
|
||||
ifcopenshell.api.attribute.edit_attributes(model, product=space, attributes={"Name": "Lobby"})
|
||||
"""
|
||||
settings = {"element": element}
|
||||
|
||||
@@ -74,7 +74,7 @@ def update_owner_history(
|
||||
# 1 IfcRoot IfcOwnerHistory
|
||||
owner_history = element[1]
|
||||
if not owner_history:
|
||||
owner_history = ifcopenshell.api.run("owner.create_owner_history", file)
|
||||
owner_history = ifcopenshell.api.owner.create_owner_history(file)
|
||||
element[1] = owner_history
|
||||
return owner_history
|
||||
|
||||
|
||||
Reference in New Issue
Block a user