2021-04-03 19:46:39 +11:00
|
|
|
import ifcopenshell.util.date
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Data:
|
|
|
|
|
is_loaded = False
|
|
|
|
|
cost_schedules = {}
|
2021-04-10 20:40:35 +10:00
|
|
|
cost_items = {}
|
2021-04-03 19:46:39 +11:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def purge(cls):
|
|
|
|
|
cls.is_loaded = False
|
|
|
|
|
cls.cost_schedules = {}
|
2021-04-10 20:40:35 +10:00
|
|
|
cls.cost_items = {}
|
2021-04-03 19:46:39 +11:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def load(cls, file):
|
|
|
|
|
cls.cost_schedules = {}
|
2021-04-10 20:40:35 +10:00
|
|
|
cls.cost_items = {}
|
|
|
|
|
|
2021-04-03 19:46:39 +11:00
|
|
|
for cost_schedule in file.by_type("IfcCostSchedule"):
|
|
|
|
|
data = cost_schedule.get_info()
|
|
|
|
|
del data["OwnerHistory"]
|
|
|
|
|
if data["SubmittedOn"]:
|
|
|
|
|
data["SubmittedOn"] = ifcopenshell.util.date.ifc2datetime(data["SubmittedOn"])
|
|
|
|
|
if data["UpdateDate"]:
|
|
|
|
|
data["UpdateDate"] = ifcopenshell.util.date.ifc2datetime(data["UpdateDate"])
|
2021-04-10 20:40:35 +10:00
|
|
|
data["RelatedObjects"] = []
|
|
|
|
|
for rel in cost_schedule.Controls:
|
|
|
|
|
for related_object in rel.RelatedObjects:
|
|
|
|
|
if related_object.is_a("IfcCostItem"):
|
|
|
|
|
data["RelatedObjects"].append(related_object.id())
|
|
|
|
|
break # We are only allowed one summary cost item
|
2021-04-03 19:46:39 +11:00
|
|
|
cls.cost_schedules[cost_schedule.id()] = data
|
2021-04-10 20:40:35 +10:00
|
|
|
|
|
|
|
|
for cost_item in file.by_type("IfcCostItem"):
|
|
|
|
|
data = cost_item.get_info()
|
|
|
|
|
del data["OwnerHistory"]
|
|
|
|
|
del data["CostValues"]
|
|
|
|
|
del data["CostQuantities"]
|
|
|
|
|
data["RelatedObjects"] = []
|
|
|
|
|
for rel in cost_item.IsNestedBy:
|
|
|
|
|
[data["RelatedObjects"].append(o.id()) for o in rel.RelatedObjects if o.is_a("IfcCostItem")]
|
|
|
|
|
cls.cost_items[cost_item.id()] = data
|
2021-04-03 19:46:39 +11:00
|
|
|
cls.is_loaded=True
|