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.

82 lines
2.9 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"])
data["RelatedObjects"] = []
for rel in work_schedule.Controls:
for obj in rel.RelatedObjects:
if obj.is_a("IfcTask"):
data["RelatedObjects"].append(obj.id())
cls.work_schedules[work_schedule.id()] = data
@classmethod
def load_work_calendars(cls):
cls.work_calendars = {}
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"):
data = task.get_info()
del data["OwnerHistory"]
data["RelatedObjects"] = []
for rel in task.IsNestedBy:
[data["RelatedObjects"].append(o.id()) for o in rel.RelatedObjects if o.is_a("IfcTask")]
cls.tasks[task.id()] = data