mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
typing
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.api
|
||||
from typing import Optional
|
||||
from typing import Optional, Any
|
||||
|
||||
|
||||
def add_application(
|
||||
@@ -68,6 +68,9 @@ def add_application(
|
||||
|
||||
|
||||
class Usecase:
|
||||
file: ifcopenshell.file
|
||||
settings: dict[str, Any]
|
||||
|
||||
def execute(self):
|
||||
if not self.settings["application_developer"]:
|
||||
self.settings["application_developer"] = self.create_application_organisation()
|
||||
|
||||
@@ -48,16 +48,14 @@ def add_role(
|
||||
identification="AWB", name="Architects Without Ballpens")
|
||||
ifcopenshell.api.owner.add_role(model, assigned_object=organisation, role="ARCHITECT")
|
||||
"""
|
||||
settings = {"assigned_object": assigned_object, "role": role}
|
||||
|
||||
element = file.createIfcActorRole("ARCHITECT")
|
||||
if settings["role"]:
|
||||
element = file.create_entity("IfcActorRole", Role="ARCHITECT")
|
||||
if role:
|
||||
try:
|
||||
element.Role = settings["role"]
|
||||
element.Role = role
|
||||
except:
|
||||
element.Role = "USERDEFINED"
|
||||
element.UserDefinedRole = settings["role"]
|
||||
roles = list(settings["assigned_object"].Roles) if settings["assigned_object"].Roles else []
|
||||
element.UserDefinedRole = role
|
||||
roles = list(assigned_object.Roles) if assigned_object.Roles else []
|
||||
roles.append(element)
|
||||
settings["assigned_object"].Roles = roles
|
||||
assigned_object.Roles = roles
|
||||
return element
|
||||
|
||||
@@ -26,11 +26,8 @@ def edit_actor(file: ifcopenshell.file, actor: ifcopenshell.entity_instance, att
|
||||
IfcActor, consult the IFC documentation.
|
||||
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
@@ -49,7 +46,5 @@ def edit_actor(file: ifcopenshell.file, actor: ifcopenshell.entity_instance, att
|
||||
ifcopenshell.api.actor.edit_actor(model,
|
||||
actor=actor, attributes={"Description": "Responsible for buildings A, B, and C."})
|
||||
"""
|
||||
settings = {"actor": actor, "attributes": attributes}
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["actor"], name, value)
|
||||
for name, value in attributes.items():
|
||||
setattr(actor, name, value)
|
||||
|
||||
@@ -26,11 +26,8 @@ def edit_address(file: ifcopenshell.file, address: ifcopenshell.entity_instance,
|
||||
IfcAddress, consult the IFC documentation.
|
||||
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
@@ -51,7 +48,5 @@ def edit_address(file: ifcopenshell.file, address: ifcopenshell.entity_instance,
|
||||
"ElectronicMailAddresses": ["bobthebuilder@example.com"],
|
||||
"WWWHomePageURL": "https://thinkmoult.com"})
|
||||
"""
|
||||
settings = {"address": address, "attributes": attributes}
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["address"], name, value)
|
||||
for name, value in attributes.items():
|
||||
setattr(address, name, value)
|
||||
|
||||
@@ -28,11 +28,8 @@ def edit_organisation(
|
||||
IfcOrganization, consult the IFC documentation.
|
||||
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
@@ -43,7 +40,5 @@ def edit_organisation(
|
||||
ifcopenshell.api.owner.edit_organisation(model, organisation=organisation,
|
||||
attributes={"name": "Architects Without Ballpens"})
|
||||
"""
|
||||
settings = {"organisation": organisation, "attributes": attributes}
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["organisation"], name, value)
|
||||
for name, value in attributes.items():
|
||||
setattr(organisation, name, value)
|
||||
|
||||
@@ -26,11 +26,8 @@ def edit_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance, a
|
||||
IfcPerson, consult the IFC documentation.
|
||||
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
@@ -41,7 +38,5 @@ def edit_person(file: ifcopenshell.file, person: ifcopenshell.entity_instance, a
|
||||
ifcopenshell.api.owner.edit_person(model, person=person,
|
||||
attributes={"MiddleNames": ["The"], "FamilyName": "Builder"})
|
||||
"""
|
||||
settings = {"person": person, "attributes": attributes}
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["person"], name, value)
|
||||
for name, value in attributes.items():
|
||||
setattr(person, name, value)
|
||||
|
||||
@@ -26,11 +26,8 @@ def edit_role(file: ifcopenshell.file, role: ifcopenshell.entity_instance, attri
|
||||
IfcActorRole, consult the IFC documentation.
|
||||
|
||||
: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
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example:
|
||||
|
||||
@@ -45,7 +42,5 @@ def edit_role(file: ifcopenshell.file, role: ifcopenshell.entity_instance, attri
|
||||
# But Bob is not an architect
|
||||
ifcopenshell.api.owner.edit_role(model, role=role, attributes={"Role": "CONSTRUCTIONMANAGER"})
|
||||
"""
|
||||
settings = {"role": role, "attributes": attributes}
|
||||
|
||||
for name, value in settings["attributes"].items():
|
||||
setattr(settings["role"], name, value)
|
||||
for name, value in attributes.items():
|
||||
setattr(role, name, value)
|
||||
|
||||
Reference in New Issue
Block a user