New assign / unassign declaration usecase, minor code & formatting cleanup

This commit is contained in:
Dion Moult
2021-04-07 13:15:16 +10:00
parent 13d4a99358
commit ae0789e4ec
25 changed files with 289 additions and 228 deletions
@@ -0,0 +1,21 @@
import ifcopenshell.util.date
class Usecase:
def __init__(self, file, **settings):
self.file = file
self.settings = {"recurrence_pattern": None, "attributes": {}}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
for name, value in self.settings["attributes"].items():
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])
}))
value = periods
setattr(self.settings["recurrence_pattern"], name, value)