mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
typing
This commit is contained in:
@@ -19,9 +19,14 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
from typing import Literal
|
||||
|
||||
|
||||
def add_actor(file, actor=None, ifc_class="IfcActor") -> None:
|
||||
def add_actor(
|
||||
file: ifcopenshell.file,
|
||||
actor: ifcopenshell.entity_instance,
|
||||
ifc_class: Literal["IfcActor", "IfcOccupant"] = "IfcActor",
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Adds a new actor
|
||||
|
||||
An actor is a person or an organisation who has a responsibility or role
|
||||
|
||||
@@ -15,9 +15,12 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
def add_address(file, assigned_object=None, ifc_class="IfcPostalAddress") -> None:
|
||||
def add_address(
|
||||
file: ifcopenshell.file, assigned_object: ifcopenshell.entity_instance, ifc_class: str = "IfcPostalAddress"
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Add a new telecom or postal address to an organisation or person
|
||||
|
||||
A person or organisation may have associated contact details such as
|
||||
|
||||
@@ -17,15 +17,16 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.api
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def add_application(
|
||||
file,
|
||||
application_developer=None,
|
||||
version=None,
|
||||
application_full_name="IfcOpenShell",
|
||||
application_identifier="IfcOpenShell",
|
||||
) -> None:
|
||||
file: ifcopenshell.file,
|
||||
application_developer: Optional[ifcopenshell.entity_instance] = None,
|
||||
version: Optional[str] = None,
|
||||
application_full_name: str = "IfcOpenShell",
|
||||
application_identifier: str = "IfcOpenShell",
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Adds a new application
|
||||
|
||||
IFC data may be associated with an authoring application to identify
|
||||
@@ -46,6 +47,8 @@ def add_application(
|
||||
:param application_identifier: An identification string for the
|
||||
application intended for computers to read.
|
||||
:type application_identifier: str, optional
|
||||
:return: The newly created IfcApplication
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ def add_person(
|
||||
identification: str = "HSeldon",
|
||||
family_name: str = "Seldon",
|
||||
given_name: str = "Hari",
|
||||
) -> None:
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Adds a new person
|
||||
|
||||
Persons are used to identify a legal or liable representative of an
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
def add_role(file, assigned_object=None, role="ARCHITECT") -> None:
|
||||
def add_role(file: ifcopenshell.file, assigned_object: ifcopenshell.entity_instance, role: str = "ARCHITECT") -> ifcopenshell.entity_instance:
|
||||
"""Adds and assigns a new role
|
||||
|
||||
People and organisations must play one or more roles on a project. Roles
|
||||
@@ -32,7 +33,7 @@ def add_role(file, assigned_object=None, role="ARCHITECT") -> None:
|
||||
be assigned to.
|
||||
:type assigned_object: ifcopenshell.entity_instance
|
||||
:param role: The type of role, taken from the IFC documentation for
|
||||
IfcActorRole, or a custom name.
|
||||
IfcActorRole, or a custom name. Defaults to "ARCHITECT".
|
||||
:type role: str, optional
|
||||
:return: The newly created IfcActorRole
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
|
||||
@@ -21,7 +21,9 @@ import ifcopenshell.api
|
||||
import ifcopenshell.guid
|
||||
|
||||
|
||||
def assign_actor(file, relating_actor=None, related_object=None) -> None:
|
||||
def assign_actor(
|
||||
file: ifcopenshell.file, relating_actor: ifcopenshell.entity_instance, related_object: ifcopenshell.entity_instance
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Assigns an actor to an object
|
||||
|
||||
An actor may be assigned to objects which implies that the actor is
|
||||
@@ -80,7 +82,7 @@ def assign_actor(file, relating_actor=None, related_object=None) -> None:
|
||||
if settings["related_object"].HasAssignments:
|
||||
for rel in settings["related_object"].HasAssignments:
|
||||
if rel.is_a("IfcRelAssignsToActor") and rel.RelatingActor == settings["relating_actor"]:
|
||||
return
|
||||
return rel
|
||||
|
||||
rel = None
|
||||
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
#
|
||||
# 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
|
||||
from typing import Any
|
||||
|
||||
|
||||
def edit_actor(file, actor=None, attributes=None) -> None:
|
||||
def edit_actor(file: ifcopenshell.file, actor: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||
"""Edits the attributes of an IfcActor
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
@@ -26,7 +28,7 @@ def edit_actor(file, actor=None, attributes=None) -> None:
|
||||
:param actor: The IfcActor entity you want to edit
|
||||
:type actor: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:type attributes: dict
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
@@ -47,7 +49,7 @@ def edit_actor(file, actor=None, attributes=None) -> None:
|
||||
ifcopenshell.api.run("actor.edit_actor", model,
|
||||
actor=actor, attributes={"Description": "Responsible for buildings A, B, and C."})
|
||||
"""
|
||||
settings = {"actor": actor, "attributes": attributes or {}}
|
||||
settings = {"actor": actor, "attributes": attributes}
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["actor"], name, value)
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
#
|
||||
# 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
|
||||
from typing import Any
|
||||
|
||||
|
||||
def edit_address(file, address=None, attributes=None) -> None:
|
||||
def edit_address(file: ifcopenshell.file, address: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||
"""Edits the attributes of an IfcAddress
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
@@ -26,7 +28,7 @@ def edit_address(file, address=None, attributes=None) -> None:
|
||||
:param address: The IfcAddress entity you want to edit
|
||||
:type address: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:type attributes: dict
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
@@ -49,7 +51,7 @@ def edit_address(file, address=None, attributes=None) -> None:
|
||||
"ElectronicMailAddresses": ["bobthebuilder@example.com"],
|
||||
"WWWHomePageURL": "https://thinkmoult.com"})
|
||||
"""
|
||||
settings = {"address": address, "attributes": attributes or {}}
|
||||
settings = {"address": address, "attributes": attributes}
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["address"], name, value)
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
#
|
||||
# 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
|
||||
from typing import Any
|
||||
|
||||
|
||||
def edit_organisation(file, organisation=None, attributes=None) -> None:
|
||||
def edit_organisation(file: ifcopenshell.file, organisation: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||
"""Edits the attributes of an IfcOrganization
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
@@ -26,7 +28,7 @@ def edit_organisation(file, organisation=None, attributes=None) -> None:
|
||||
:param organisation: The IfcOrganization entity you want to edit
|
||||
:type organisation: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:type attributes: dict
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
@@ -39,7 +41,7 @@ def edit_organisation(file, organisation=None, attributes=None) -> None:
|
||||
ifcopenshell.api.run("owner.edit_organisation", model, organisation=organisation,
|
||||
attributes={"name": "Architects Without Ballpens"})
|
||||
"""
|
||||
settings = {"organisation": organisation, "attributes": attributes or {}}
|
||||
settings = {"organisation": organisation, "attributes": attributes}
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["organisation"], name, value)
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
#
|
||||
# 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
|
||||
from typing import Any
|
||||
|
||||
|
||||
def edit_person(file, person=None, attributes=None) -> None:
|
||||
def edit_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||
"""Edits the attributes of an IfcPerson
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
@@ -26,7 +28,7 @@ def edit_person(file, person=None, attributes=None) -> None:
|
||||
:param person: The IfcPerson entity you want to edit
|
||||
:type person: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:type attributes: dict
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
@@ -39,7 +41,7 @@ def edit_person(file, person=None, attributes=None) -> None:
|
||||
ifcopenshell.api.run("owner.edit_person", model, person=person,
|
||||
attributes={"MiddleNames": ["The"], "FamilyName": "Builder"})
|
||||
"""
|
||||
settings = {"person": person, "attributes": attributes or {}}
|
||||
settings = {"person": person, "attributes": attributes}
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["person"], name, value)
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
#
|
||||
# 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
|
||||
from typing import Any
|
||||
|
||||
|
||||
def edit_role(file, role=None, attributes=None) -> None:
|
||||
def edit_role(file: ifcopenshell.file, role: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
|
||||
"""Edits the attributes of an IfcActorRole
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
@@ -26,7 +28,7 @@ def edit_role(file, role=None, attributes=None) -> None:
|
||||
:param role: The IfcActorRole entity you want to edit
|
||||
:type role: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:type attributes: dict
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
@@ -43,7 +45,7 @@ def edit_role(file, role=None, attributes=None) -> None:
|
||||
# But Bob is not an architect
|
||||
ifcopenshell.api.run("owner.edit_role", model, role=role, attributes={"Role": "CONSTRUCTIONMANAGER"})
|
||||
"""
|
||||
settings = {"role": role, "attributes": attributes or {}}
|
||||
settings = {"role": role, "attributes": attributes}
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["role"], name, value)
|
||||
|
||||
@@ -20,7 +20,7 @@ import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
def remove_actor(file, actor=None) -> None:
|
||||
def remove_actor(file: ifcopenshell.file, actor: ifcopenshell.entity_instance) -> None:
|
||||
"""Removes an actor
|
||||
|
||||
:param actor: The IfcActor to remove.
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
def remove_address(file, address=None) -> None:
|
||||
def remove_address(file: ifcopenshell.file, address: ifcopenshell.entity_instance) -> None:
|
||||
"""Removes an address
|
||||
|
||||
Naturally, any organisations or people using that address will have the
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
def remove_application(file, application=None) -> None:
|
||||
def remove_application(file: ifcopenshell.file, application: ifcopenshell.entity_instance) -> None:
|
||||
"""Removes an application
|
||||
|
||||
Warning: removing an application may invalidate ownership histories.
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
def remove_organisation(file, organisation=None) -> None:
|
||||
def remove_organisation(file: ifcopenshell.file, organisation: ifcopenshell.entity_instance) -> None:
|
||||
"""Remove an organisation
|
||||
|
||||
All roles and addresses assigned to the organisation will also be
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
def remove_person(file, person=None) -> None:
|
||||
def remove_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance) -> None:
|
||||
"""Remove an person
|
||||
|
||||
All roles and addresses assigned to the person will also be
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
def remove_person_and_organisation(file, person_and_organisation=None) -> None:
|
||||
def remove_person_and_organisation(
|
||||
file: ifcopenshell.file, person_and_organisation: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
"""Removes a person and organisation
|
||||
|
||||
Note that the underlying person and organisation is not removed, only
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
def remove_role(file, role=None) -> None:
|
||||
def remove_role(file: ifcopenshell.file, role: ifcopenshell.entity_instance) -> None:
|
||||
"""Removes a role
|
||||
|
||||
People and organisations using the role will be untouched. This may
|
||||
|
||||
@@ -21,7 +21,9 @@ import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
def unassign_actor(file, relating_actor=None, related_object=None) -> None:
|
||||
def unassign_actor(
|
||||
file: ifcopenshell.file, relating_actor: ifcopenshell.entity_instance, related_object: ifcopenshell.entity_instance
|
||||
) -> None:
|
||||
"""Unassigns an actor to an object
|
||||
|
||||
This means that the actor is no longer responsible for the object.
|
||||
@@ -30,9 +32,8 @@ def unassign_actor(file, relating_actor=None, related_object=None) -> None:
|
||||
:type relating_actor: ifcopenshell.entity_instance
|
||||
:param related_object: The object the actor is responsible for.
|
||||
:type related_object: ifcopenshell.entity_instance
|
||||
:return: The updated IfcRelAssignsToActor relationship or none if there
|
||||
is no more valid relationship.
|
||||
:rtype: None, ifcopenshell.entity_instance
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
@@ -72,4 +73,3 @@ def unassign_actor(file, relating_actor=None, related_object=None) -> None:
|
||||
related_objects.remove(settings["related_object"])
|
||||
rel.RelatedObjects = related_objects
|
||||
ifcopenshell.api.run("owner.update_owner_history", file, **{"element": rel})
|
||||
return rel
|
||||
|
||||
Reference in New Issue
Block a user