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

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

71 lines
2.4 KiB
Python
Raw Normal View History

import ifcopenshell.util.date
2021-02-17 22:54:11 +11:00
class Data:
is_loaded = False
work_plans = {}
work_schedules = {}
2021-02-17 22:54:11 +11:00
tasks = {}
@classmethod
def purge(cls):
cls.is_loaded = False
cls.work_plans = {}
cls.work_schedules = {}
cls.work_calendars = {}
2021-02-17 22:54:11 +11:00
cls.tasks = {}
@classmethod
def load(cls, file):
2021-04-07 00:04:57 +01:00
cls._file = file
if not cls._file:
return
cls.load_work_plans()
cls.load_work_schedules()
cls.load_work_calendars()
2021-04-07 00:04:57 +01:00
cls.load_tasks()
cls.is_loaded = True
2021-04-07 00:04:57 +01:00
@classmethod
def load_work_plans(cls):
cls.work_plans = {}
2021-04-07 00:04:57 +01:00
for work_plan in cls._file.by_type("IfcWorkPlan"):
data = work_plan.get_info()
del data["OwnerHistory"]
if data["Creators"]:
data["Creators"] = [p.id() for p in data["Creators"]]
data["CreationDate"] = ifcopenshell.util.date.ifc2datetime(data["CreationDate"])
data["StartTime"] = ifcopenshell.util.date.ifc2datetime(data["StartTime"])
if data["FinishTime"]:
data["FinishTime"] = ifcopenshell.util.date.ifc2datetime(data["FinishTime"])
cls.work_plans[work_plan.id()] = data
2021-04-07 00:04:57 +01:00
@classmethod
def load_work_schedules(cls):
cls.work_schedules = {}
for work_schedule in cls._file.by_type("IfcWorkSchedule"):
data = work_schedule.get_info()
del data["OwnerHistory"]
if data["Creators"]:
data["Creators"] = [p.id() for p in data["Creators"]]
data["CreationDate"] = ifcopenshell.util.date.ifc2datetime(data["CreationDate"])
data["StartTime"] = ifcopenshell.util.date.ifc2datetime(data["StartTime"])
if data["FinishTime"]:
data["FinishTime"] = ifcopenshell.util.date.ifc2datetime(data["FinishTime"])
cls.work_schedules[work_schedule.id()] = data
@classmethod
def load_work_calendars(cls):
for work_calendar in cls._file.by_type("IfcWorkCalendar"):
data = work_calendar.get_info()
del data["OwnerHistory"]
del data["WorkingTimes"]
del data["ExceptionTimes"]
cls.work_calendars[work_calendar.id()] = data
2021-04-07 00:04:57 +01:00
@classmethod
def load_tasks(cls):
cls.tasks = {}
for task in cls._file.by_type("IfcTask"):
2021-02-17 22:54:11 +11:00
cls.tasks[task.id()] = {"Name": task.Name, "Identification": task.Identification or ""}