Files
IfcOpenShell/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_time.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
910 B
Python
Raw Normal View History

class Usecase:
def __init__(self, file, **settings):
self.file = file
self.settings = {"work_calendar": None, "type": "WorkingTimes", "name": None}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
work_time = self.file.create_entity("IfcWorkTime", **{"Name": self.settings["name"]})
if self.settings["type"] == "WorkingTimes":
working_times = list(self.settings["work_calendar"].WorkingTimes or [])
working_times.append(work_time)
self.settings["work_calendar"].WorkingTimes = working_times
elif self.settings["type"] == "ExceptionTimes":
exception_times = list(self.settings["work_calendar"].ExceptionTimes or [])
exception_times.append(work_time)
self.settings["work_calendar"].WorkingTimes = exception_times
return work_time