Cost values are now serialised and shown as formulas

This commit is contained in:
Dion Moult
2021-08-26 21:37:14 +10:00
parent c96d1e6387
commit 5e1fbacef7
4 changed files with 154 additions and 2 deletions
@@ -592,12 +592,15 @@ class AddCostValue(bpy.types.Operator):
self.file = IfcStore.get_file()
if self.cost_type == "FIXED":
category = None
attributes = {"AppliedValue": 0.0}
elif self.cost_type == "SUM":
category = "*"
attributes = {"Category": category}
elif self.cost_type == "CATEGORY":
category = self.cost_category
attributes = {"Category": category}
value = ifcopenshell.api.run("cost.add_cost_value", self.file, parent=self.file.by_id(self.parent))
ifcopenshell.api.run("cost.edit_cost_value", self.file, cost_value=value, attributes={"Category": category})
ifcopenshell.api.run("cost.edit_cost_value", self.file, cost_value=value, attributes=attributes)
Data.load(self.file)
return {"FINISHED"}
@@ -646,8 +649,11 @@ class EnableEditingCostItemValue(bpy.types.Operator):
def import_attributes(self, name, prop, data, context):
if name == "AppliedValue":
# TODO: for now, only support simple values
# TODO: for now, only support simple IfcValues (which are effectively IfcMonetaryMeasure)
prop = self.props.cost_value_attributes.add()
prop.data_type = "float"
prop.name = "AppliedValue"
prop.is_optional = True
prop.float_value = 0.0 if prop.is_null else data[name]
return True
if (
@@ -190,6 +190,7 @@ class BIM_PT_cost_schedules(Panel):
for cost_value_id in Data.cost_items[self.props.active_cost_item_id]["CostValues"]:
row = self.layout.row(align=True)
row.label(text=Data.cost_values[cost_value_id]["Formula"])
self.draw_readonly_cost_value_ui(row, cost_value_id)
if self.props.active_cost_item_value_id: