mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
See #7716. Fix util get_cost_item_for_product
Before there was an error if there weren't assignments now it should be fixed. Add also tests.
This commit is contained in:
committed by
Massimo Fabbro
parent
6b2d25a5e5
commit
5febbc1391
@@ -196,9 +196,12 @@ def get_cost_items_for_product(product: ifcopenshell.entity_instance) -> list[if
|
||||
:return: A list of IfcCostItem objects representing the cost items related to the product.
|
||||
"""
|
||||
cost_items = []
|
||||
for assignment in product.HasAssignments:
|
||||
if assignment.is_a("IfcRelAssignsToControl") and assignment.RelatingControl.is_a("IfcCostItem"):
|
||||
cost_items.append(assignment.RelatingControl)
|
||||
for assignment in product.HasAssignments or []:
|
||||
if assignment.is_a("IfcRelAssignsToControl"):
|
||||
control = assignment.RelatingControl
|
||||
if control and control.is_a("IfcCostItem"):
|
||||
cost_items.append(control)
|
||||
|
||||
return cost_items
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user