mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +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):
|
def _get_object_quantities(cls, cost_item, element):
|
||||||
if not element.is_a("IfcObject"):
|
if not element.is_a("IfcObject"):
|
||||||
return []
|
return []
|
||||||
|
cost_quantities = cost_item.CostQuantities
|
||||||
|
if not cost_quantities:
|
||||||
|
return []
|
||||||
results = []
|
results = []
|
||||||
for relationship in element.IsDefinedBy:
|
for relationship in element.IsDefinedBy:
|
||||||
if not relationship.is_a("IfcRelDefinesByProperties"):
|
if not relationship.is_a("IfcRelDefinesByProperties"):
|
||||||
@@ -210,7 +213,7 @@ class CostSchedulesData:
|
|||||||
if not qto.is_a("IfcElementQuantity"):
|
if not qto.is_a("IfcElementQuantity"):
|
||||||
continue
|
continue
|
||||||
for prop in qto.Quantities:
|
for prop in qto.Quantities:
|
||||||
if prop in cost_item.CostQuantities or []:
|
if prop in cost_quantities:
|
||||||
results.append(prop.id())
|
results.append(prop.id())
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|||||||
@@ -171,26 +171,25 @@ class IfcDataGetter:
|
|||||||
take_off_name = "mixed-takeoff-quantities"
|
take_off_name = "mixed-takeoff-quantities"
|
||||||
return quantity[3]
|
return quantity[3]
|
||||||
|
|
||||||
if not cost_item:
|
|
||||||
return None
|
|
||||||
take_off_name = ""
|
take_off_name = ""
|
||||||
has_changed_name = False
|
|
||||||
total_cost_quantity = 0
|
total_cost_quantity = 0
|
||||||
accounted_for = []
|
accounted_for = []
|
||||||
for rel in cost_item.Controls or []:
|
cost_item_quantities = cost_item.CostQuantities
|
||||||
for related_object in rel.RelatedObjects:
|
if cost_item_quantities:
|
||||||
qtos = ifcopenshell.util.element.get_psets(related_object, qtos_only=True)
|
for rel in cost_item.Controls or []:
|
||||||
for quantities in qtos.values() or []:
|
for related_object in rel.RelatedObjects:
|
||||||
qto = file.by_id(quantities["id"])
|
qtos = ifcopenshell.util.element.get_psets(related_object, qtos_only=True)
|
||||||
for quantity in qto.Quantities:
|
for quantities in qtos.values() or []:
|
||||||
if not quantity in cost_item.CostQuantities:
|
qto = file.by_id(quantities["id"])
|
||||||
continue
|
for quantity in qto.Quantities:
|
||||||
total_cost_quantity += add_quantity(quantity, take_off_name)
|
if quantity not in cost_item_quantities:
|
||||||
accounted_for.append(quantity)
|
continue
|
||||||
|
total_cost_quantity += add_quantity(quantity, take_off_name)
|
||||||
|
accounted_for.append(quantity)
|
||||||
|
|
||||||
for quantity in cost_item.CostQuantities or []:
|
for quantity in cost_item_quantities:
|
||||||
if not quantity in accounted_for:
|
if not quantity in accounted_for:
|
||||||
total_cost_quantity += add_quantity(quantity, take_off_name)
|
total_cost_quantity += add_quantity(quantity, take_off_name)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"id": cost_item.id(),
|
"id": cost_item.id(),
|
||||||
|
|||||||
Reference in New Issue
Block a user