mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 14:33:28 +00:00
fix resource cost calculation
This commit is contained in:
@@ -119,15 +119,16 @@ def get_nested_resources(resource):
|
|||||||
|
|
||||||
|
|
||||||
def get_cost(resource):
|
def get_cost(resource):
|
||||||
|
base_costs = getattr(resource, "BaseCosts", [])
|
||||||
costs = [
|
costs = [
|
||||||
ifcopenshell.util.cost.calculate_applied_value(resource, cost_value)
|
ifcopenshell.util.cost.calculate_applied_value(resource, cost_value)
|
||||||
for cost_value in getattr(resource, "BaseCosts", [])
|
for cost_value in base_costs
|
||||||
]
|
] if base_costs else []
|
||||||
cost = costs[0] if costs else None
|
cost = sum(costs)
|
||||||
unit_basis = next(
|
unit_basis = next(
|
||||||
(cost_value.UnitBasis for cost_value in getattr(resource, "BaseCosts", []) if cost_value.UnitBasis),
|
(cost_value.UnitBasis for cost_value in base_costs if cost_value.UnitBasis),
|
||||||
None
|
None
|
||||||
)
|
) if base_costs else None
|
||||||
unit = unit_basis.UnitComponent.Name if unit_basis and unit_basis.UnitComponent.is_a("IfcConversionBasedUnit") else None
|
unit = unit_basis.UnitComponent.Name if unit_basis and unit_basis.UnitComponent.is_a("IfcConversionBasedUnit") else None
|
||||||
return cost, unit
|
return cost, unit
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user