mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
fix error exporting schedule of rates #4723
Issue occurred when cost item would have no quantities but had controlled objects with quantities. 1) just added a check to ensure that cost_item.CostQuantities are present 2) removed possible None return value in get_cost_item_quantity as it actually will break process_cost_data and it's never used anywhere else 3) has_changed_name was unused 4) fix possible similar issue in cost.data (though _get_object_quantities method is unused)
This commit is contained in:
@@ -202,6 +202,9 @@ class CostSchedulesData:
|
||||
def _get_object_quantities(cls, cost_item, element):
|
||||
if not element.is_a("IfcObject"):
|
||||
return []
|
||||
cost_quantities = cost_item.CostQuantities
|
||||
if not cost_quantities:
|
||||
return []
|
||||
results = []
|
||||
for relationship in element.IsDefinedBy:
|
||||
if not relationship.is_a("IfcRelDefinesByProperties"):
|
||||
@@ -210,7 +213,7 @@ class CostSchedulesData:
|
||||
if not qto.is_a("IfcElementQuantity"):
|
||||
continue
|
||||
for prop in qto.Quantities:
|
||||
if prop in cost_item.CostQuantities or []:
|
||||
if prop in cost_quantities:
|
||||
results.append(prop.id())
|
||||
return results
|
||||
|
||||
|
||||
@@ -171,26 +171,25 @@ class IfcDataGetter:
|
||||
take_off_name = "mixed-takeoff-quantities"
|
||||
return quantity[3]
|
||||
|
||||
if not cost_item:
|
||||
return None
|
||||
take_off_name = ""
|
||||
has_changed_name = False
|
||||
total_cost_quantity = 0
|
||||
accounted_for = []
|
||||
for rel in cost_item.Controls or []:
|
||||
for related_object in rel.RelatedObjects:
|
||||
qtos = ifcopenshell.util.element.get_psets(related_object, qtos_only=True)
|
||||
for quantities in qtos.values() or []:
|
||||
qto = file.by_id(quantities["id"])
|
||||
for quantity in qto.Quantities:
|
||||
if not quantity in cost_item.CostQuantities:
|
||||
continue
|
||||
total_cost_quantity += add_quantity(quantity, take_off_name)
|
||||
accounted_for.append(quantity)
|
||||
cost_item_quantities = cost_item.CostQuantities
|
||||
if cost_item_quantities:
|
||||
for rel in cost_item.Controls or []:
|
||||
for related_object in rel.RelatedObjects:
|
||||
qtos = ifcopenshell.util.element.get_psets(related_object, qtos_only=True)
|
||||
for quantities in qtos.values() or []:
|
||||
qto = file.by_id(quantities["id"])
|
||||
for quantity in qto.Quantities:
|
||||
if quantity not in cost_item_quantities:
|
||||
continue
|
||||
total_cost_quantity += add_quantity(quantity, take_off_name)
|
||||
accounted_for.append(quantity)
|
||||
|
||||
for quantity in cost_item.CostQuantities or []:
|
||||
if not quantity in accounted_for:
|
||||
total_cost_quantity += add_quantity(quantity, take_off_name)
|
||||
for quantity in cost_item_quantities:
|
||||
if not quantity in accounted_for:
|
||||
total_cost_quantity += add_quantity(quantity, take_off_name)
|
||||
|
||||
return {
|
||||
"id": cost_item.id(),
|
||||
|
||||
Reference in New Issue
Block a user