mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +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:
@@ -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