mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
New feature to manipulate cost item quantities
This commit is contained in:
@@ -5,17 +5,20 @@ class Data:
|
||||
is_loaded = False
|
||||
cost_schedules = {}
|
||||
cost_items = {}
|
||||
physical_quantities = {}
|
||||
|
||||
@classmethod
|
||||
def purge(cls):
|
||||
cls.is_loaded = False
|
||||
cls.cost_schedules = {}
|
||||
cls.cost_items = {}
|
||||
cls.physical_quantities = {}
|
||||
|
||||
@classmethod
|
||||
def load(cls, file):
|
||||
cls.cost_schedules = {}
|
||||
cls.cost_items = {}
|
||||
cls.physical_quantities = {}
|
||||
|
||||
for cost_schedule in file.by_type("IfcCostSchedule"):
|
||||
data = cost_schedule.get_info()
|
||||
@@ -36,7 +39,6 @@ class Data:
|
||||
data = cost_item.get_info()
|
||||
del data["OwnerHistory"]
|
||||
del data["CostValues"]
|
||||
del data["CostQuantities"]
|
||||
data["RelatedObjects"] = []
|
||||
data["Controls"] = []
|
||||
for rel in cost_item.IsNestedBy:
|
||||
@@ -44,4 +46,16 @@ class Data:
|
||||
for rel in cost_item.Controls:
|
||||
[data["Controls"].append(o.id()) for o in rel.RelatedObjects or []]
|
||||
cls.cost_items[cost_item.id()] = data
|
||||
cls.load_cost_item_quantities(cost_item, data)
|
||||
cls.is_loaded=True
|
||||
|
||||
@classmethod
|
||||
def load_cost_item_quantities(cls, cost_item, data):
|
||||
data["CostQuantities"] = []
|
||||
data["TotalCostQuantities"] = 0.0
|
||||
for quantity in cost_item.CostQuantities or []:
|
||||
quantity_data = quantity.get_info()
|
||||
del quantity_data["Unit"]
|
||||
cls.physical_quantities[quantity.id()] = quantity_data
|
||||
data["CostQuantities"].append(quantity.id())
|
||||
data["TotalCostQuantities"] += quantity[3]
|
||||
|
||||
Reference in New Issue
Block a user