diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_recurrence_pattern.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_recurrence_pattern.py new file mode 100644 index 0000000000..2e4d830584 --- /dev/null +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_recurrence_pattern.py @@ -0,0 +1,15 @@ +import ifcopenshell.api + + +class Usecase: + def __init__(self, file, **settings): + self.file = file + self.settings = {"work_time": None, "recurrence_type": None} + for key, value in settings.items(): + self.settings[key] = value + + def execute(self): + recurrence_pattern = self.file.create_entity("IfcRecurrencePattern") + recurrence_pattern.RecurrenceType = self.settings["recurrence_type"] + self.settings["work_time"].RecurrencePattern = recurrence_pattern + return recurrence_pattern diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_time_period.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_time_period.py new file mode 100644 index 0000000000..a323a6a553 --- /dev/null +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_time_period.py @@ -0,0 +1,25 @@ +import ifcopenshell.api +import ifcopenshell.util.date +from datetime import datetime +from datetime import timedelta + + +class Usecase: + def __init__(self, file, **settings): + self.file = file + self.settings = { + "recurrence_pattern": None, + "start_time": None, + "end_time": None, + } + for key, value in settings.items(): + self.settings[key] = value + + def execute(self): + time_period = self.file.create_entity("IfcTimePeriod") + time_period.StartTime = ifcopenshell.util.date.datetime2ifc(self.settings["start_time"], "IfcTime") + time_period.EndTime = ifcopenshell.util.date.datetime2ifc(self.settings["end_time"], "IfcTime") + time_periods = list(self.settings["recurrence_pattern"].TimePeriods or []) + time_periods.append(time_period) + self.settings["recurrence_pattern"].TimePeriods = time_periods + return time_period diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_time.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_time.py index 40589b5098..b5a7eedbf9 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_time.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_work_time.py @@ -1,12 +1,12 @@ class Usecase: def __init__(self, file, **settings): self.file = file - self.settings = {"work_calendar": None, "type": "WorkingTimes", "name": None} + self.settings = {"work_calendar": None, "time_type": 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"]}) + work_time = self.file.create_entity("IfcWorkTime") if self.settings["type"] == "WorkingTimes": working_times = list(self.settings["work_calendar"].WorkingTimes or []) working_times.append(work_time) diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_recurrence_pattern.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_recurrence_pattern.py index ee57a173bc..f7691ad4e3 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_recurrence_pattern.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/edit_recurrence_pattern.py @@ -13,9 +13,14 @@ class Usecase: if name == "TimePeriods" and value: periods = [] for period in value: - periods.append(self.file.create_entity("IfcTimePeriod", **{ - "StartTime": ifcopenshell.util.date.datetime2ifc(period[0]), - "EndTime": ifcopenshell.util.date.datetime2ifc(period[1]) - })) + periods.append( + self.file.create_entity( + "IfcTimePeriod", + **{ + "StartTime": ifcopenshell.util.date.datetime2ifc(period[0]), + "EndTime": ifcopenshell.util.date.datetime2ifc(period[1]), + }, + ) + ) value = periods setattr(self.settings["recurrence_pattern"], name, value) diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_recurrence_pattern.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_recurrence_pattern.py new file mode 100644 index 0000000000..23ec89376a --- /dev/null +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_recurrence_pattern.py @@ -0,0 +1,12 @@ +import ifcopenshell.api + + +class Usecase: + def __init__(self, file, **settings): + self.file = file + self.settings = {"recurrence_pattern": None} + for key, value in settings.items(): + self.settings[key] = value + + def execute(self): + self.file.remove(self.settings["recurrence_pattern"]) diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_time_period.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_time_period.py new file mode 100644 index 0000000000..4b0d59d7aa --- /dev/null +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_time_period.py @@ -0,0 +1,12 @@ +import ifcopenshell.api + + +class Usecase: + def __init__(self, file, **settings): + self.file = file + self.settings = {"time_period": None} + for key, value in settings.items(): + self.settings[key] = value + + def execute(self): + self.file.remove(self.settings["time_period"]) diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_time.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_time.py new file mode 100644 index 0000000000..10562c1840 --- /dev/null +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/remove_work_time.py @@ -0,0 +1,9 @@ +class Usecase: + def __init__(self, file, **settings): + self.file = file + self.settings = {"work_time": None} + for key, value in settings.items(): + self.settings[key] = value + + def execute(self): + self.file.remove(self.settings["work_time"])