mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Generate functions for all API usecases for better static code features. See #2693.
This commit is contained in:
@@ -19,43 +19,40 @@
|
||||
import ifcopenshell.util.date
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, work_schedule=None, attributes=None):
|
||||
"""Edits the attributes of an IfcWorkSchedule
|
||||
def edit_work_schedule(file, work_schedule=None, attributes=None) -> None:
|
||||
"""Edits the attributes of an IfcWorkSchedule
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
IfcWorkSchedule, consult the IFC documentation.
|
||||
For more information about the attributes and data types of an
|
||||
IfcWorkSchedule, consult the IFC documentation.
|
||||
|
||||
:param work_schedule: The IfcWorkSchedule entity you want to edit
|
||||
:type work_schedule: ifcopenshell.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:return: None
|
||||
:rtype: None
|
||||
:param work_schedule: The IfcWorkSchedule entity you want to edit
|
||||
:type work_schedule: 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
|
||||
|
||||
# This will hold all our construction schedules
|
||||
work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
|
||||
# This will hold all our construction schedules
|
||||
work_plan = ifcopenshell.api.run("sequence.add_work_plan", model, name="Construction")
|
||||
|
||||
# Let's imagine this is one of our schedules in our work plan.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model,
|
||||
name="Construction Schedule A", work_plan=work_plan)
|
||||
# Let's imagine this is one of our schedules in our work plan.
|
||||
schedule = ifcopenshell.api.run("sequence.add_work_schedule", model,
|
||||
name="Construction Schedule A", work_plan=work_plan)
|
||||
|
||||
# Let's give it a description
|
||||
ifcopenshell.api.run("sequence.edit_work_schedule", model,
|
||||
work_schedule=work_schedule, attributes={"Description": "3 crane design option"})
|
||||
"""
|
||||
self.file = file
|
||||
self.settings = {"work_schedule": work_schedule, "attributes": attributes or {}}
|
||||
# Let's give it a description
|
||||
ifcopenshell.api.run("sequence.edit_work_schedule", model,
|
||||
work_schedule=work_schedule, attributes={"Description": "3 crane design option"})
|
||||
"""
|
||||
settings = {"work_schedule": work_schedule, "attributes": attributes or {}}
|
||||
|
||||
def execute(self):
|
||||
for name, value in self.settings["attributes"].items():
|
||||
if value:
|
||||
if "Date" in name or "Time" in name:
|
||||
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDateTime")
|
||||
elif name == "Duration" or name == "TotalFloat":
|
||||
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDuration")
|
||||
setattr(self.settings["work_schedule"], name, value)
|
||||
for name, value in settings["attributes"].items():
|
||||
if value:
|
||||
if "Date" in name or "Time" in name:
|
||||
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDateTime")
|
||||
elif name == "Duration" or name == "TotalFloat":
|
||||
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDuration")
|
||||
setattr(settings["work_schedule"], name, value)
|
||||
|
||||
Reference in New Issue
Block a user