Generate functions for all API usecases for better static code features. See #2693.

This commit is contained in:
Dion Moult
2024-05-06 14:35:39 +10:00
parent 10f894e2ea
commit d11ec67129
330 changed files with 13283 additions and 13751 deletions
@@ -17,40 +17,37 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
class Usecase:
def __init__(self, file, actor=None, attributes=None):
"""Edits the attributes of an IfcActor
def edit_actor(file, actor=None, attributes=None) -> None:
"""Edits the attributes of an IfcActor
For more information about the attributes and data types of an
IfcActor, consult the IFC documentation.
For more information about the attributes and data types of an
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, optional
:return: None
:rtype: 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
:return: None
:rtype: None
Example:
Example:
.. code:: python
.. code:: python
# Setup an organisation with a single role
organisation = ifcopenshell.api.run("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"})
# Setup an organisation with a single role
organisation = ifcopenshell.api.run("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"})
# Assign that organisation to a newly created actor
actor = ifcopenshell.api.run("owner.add_actor", model, actor=organisation)
# Assign that organisation to a newly created actor
actor = ifcopenshell.api.run("owner.add_actor", model, actor=organisation)
# Edit the description of the attribute.
ifcopenshell.api.run("actor.edit_actor", model,
actor=actor, attributes={"Description": "Responsible for buildings A, B, and C."})
"""
self.file = file
self.settings = {"actor": actor, "attributes": attributes or {}}
# Edit the description of the attribute.
ifcopenshell.api.run("actor.edit_actor", model,
actor=actor, attributes={"Description": "Responsible for buildings A, B, and C."})
"""
settings = {"actor": actor, "attributes": attributes or {}}
def execute(self):
for name, value in self.settings["attributes"].items():
setattr(self.settings["actor"], name, value)
for name, value in settings["attributes"].items():
setattr(settings["actor"], name, value)