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.

44 lines
1.3 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 = {}
2021-02-17 22:54:11 +11:00
tasks = {}
@classmethod
def purge(cls):
cls.is_loaded = False
cls.work_plans = {}
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_tasks()
cls.is_loaded=True
@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"]]
2021-04-07 00:04:57 +01:00
data["CreationDate"] = ifcopenshell.util.date.ifc2datetime(data["CreationDate"]).isoformat()
data["StartTime"] = ifcopenshell.util.date.ifc2datetime(data["StartTime"]).isoformat()
if data["FinishTime"]:
2021-04-07 00:04:57 +01:00
data["FinishTime"] = ifcopenshell.util.date.ifc2datetime(data["FinishTime"]).isoformat()
cls.work_plans[work_plan.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 ""}