mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
fix bug with cost schedules confusing 0 quantity with no quantities
a bit related to #4704 1) fixed util.cost.get_total_quantity 2) fixed similar issue in cost.data that calculates the final value that user will see in UI 3) changed UI, "-" is shown when there are no quantities and "0" is when quantities are there but they just equal to zero. Before - https://i.imgur.com/EO53DhM.png After - https://i.imgur.com/H6rK4sP.png fyi @myoualid
This commit is contained in:
@@ -140,7 +140,7 @@ class CostSchedulesData:
|
||||
data["UnitBasisUnitSymbol"] = "U"
|
||||
if cost_value.Category == "*":
|
||||
is_sum = True
|
||||
cost_quantity = data["TotalCostQuantity"] or 1
|
||||
cost_quantity = 1 if data["TotalCostQuantity"] is None else data["TotalCostQuantity"]
|
||||
if has_unit_basis:
|
||||
data["TotalCost"] = data["TotalAppliedValue"] * cost_quantity / data["UnitBasisValueComponent"]
|
||||
else:
|
||||
|
||||
@@ -634,7 +634,7 @@ class BIM_UL_cost_items_trait:
|
||||
layout.label(text=cost_item["UnitBasisUnitSymbol"])
|
||||
|
||||
def draw_total_quantity_column(self, layout, cost_item):
|
||||
if cost_item["TotalCostQuantity"]:
|
||||
if cost_item["TotalCostQuantity"] is not None:
|
||||
label = "{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" {cost_item['UnitSymbol'] or '-'}"
|
||||
layout.label(text=label)
|
||||
else:
|
||||
|
||||
@@ -40,7 +40,12 @@ def get_primitive_applied_value(applied_value: Union[ifcopenshell.entity_instanc
|
||||
def get_total_quantity(root_element: ifcopenshell.entity_instance) -> Union[float, None]:
|
||||
# 3 IfcPhysicalQuantity Value
|
||||
if root_element.is_a("IfcCostItem"):
|
||||
return sum([q[3] for q in root_element.CostQuantities or []]) or None
|
||||
# Different output for no quantities and zero quantites
|
||||
# as they have different meaning in IFC.
|
||||
quantities = root_element.CostQuantities
|
||||
if not quantities:
|
||||
return None
|
||||
return sum([q[3] for q in quantities])
|
||||
elif root_element.is_a("IfcConstructionResource"):
|
||||
quantity = root_element.BaseQuantity
|
||||
return quantity[3] if quantity else 1.0
|
||||
|
||||
Reference in New Issue
Block a user