mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
fix the bug fix #07b5c49 - where counting objects controlled by a cost item stopped working
This commit is contained in:
@@ -88,28 +88,31 @@ class Usecase:
|
|||||||
self.quantities = set(self.settings["cost_item"].CostQuantities or [])
|
self.quantities = set(self.settings["cost_item"].CostQuantities or [])
|
||||||
print(self.settings["cost_item"].CostQuantities)
|
print(self.settings["cost_item"].CostQuantities)
|
||||||
for product in self.settings["products"]:
|
for product in self.settings["products"]:
|
||||||
|
self.assign_cost_control(
|
||||||
|
related_object=product, cost_item=self.settings["cost_item"]
|
||||||
|
)
|
||||||
if self.settings["prop_name"]:
|
if self.settings["prop_name"]:
|
||||||
if (
|
if (
|
||||||
self.settings["cost_item"].CostQuantities
|
self.settings["cost_item"].CostQuantities
|
||||||
and self.settings["cost_item"].CostQuantities[0].Name.lower()
|
and self.settings["cost_item"].CostQuantities[0].Name.lower()
|
||||||
!= self.settings["prop_name"].lower()
|
!= self.settings["prop_name"].lower()
|
||||||
):
|
) or not product.is_a("IfcObject"):
|
||||||
continue
|
continue
|
||||||
ifcopenshell.api.run(
|
|
||||||
"control.assign_control",
|
|
||||||
self.file,
|
|
||||||
related_object=product,
|
|
||||||
relating_control=self.settings["cost_item"],
|
|
||||||
)
|
|
||||||
self.add_quantity_from_related_object(product)
|
self.add_quantity_from_related_object(product)
|
||||||
if self.settings["prop_name"]:
|
if self.settings["prop_name"]:
|
||||||
self.settings["cost_item"].CostQuantities = list(self.quantities)
|
self.settings["cost_item"].CostQuantities = list(self.quantities)
|
||||||
else:
|
else:
|
||||||
self.update_cost_item_count()
|
self.update_cost_item_count()
|
||||||
|
|
||||||
|
def assign_cost_control(self, related_object, cost_item):
|
||||||
|
return ifcopenshell.api.run(
|
||||||
|
"control.assign_control",
|
||||||
|
self.file,
|
||||||
|
related_object=related_object,
|
||||||
|
relating_control=cost_item,
|
||||||
|
)
|
||||||
|
|
||||||
def add_quantity_from_related_object(self, element):
|
def add_quantity_from_related_object(self, element):
|
||||||
if not element.is_a("IfcObject"):
|
|
||||||
return
|
|
||||||
for relationship in element.IsDefinedBy:
|
for relationship in element.IsDefinedBy:
|
||||||
if relationship.is_a("IfcRelDefinesByProperties"):
|
if relationship.is_a("IfcRelDefinesByProperties"):
|
||||||
self.add_quantity_from_qto(relationship.RelatingPropertyDefinition)
|
self.add_quantity_from_qto(relationship.RelatingPropertyDefinition)
|
||||||
@@ -128,7 +131,7 @@ class Usecase:
|
|||||||
# This is a bold assumption
|
# This is a bold assumption
|
||||||
# https://forums.buildingsmart.org/t/how-does-a-cost-item-know-that-it-is-counting-a-controlled-product/3564
|
# https://forums.buildingsmart.org/t/how-does-a-cost-item-know-that-it-is-counting-a-controlled-product/3564
|
||||||
if not self.settings["cost_item"].CostQuantities:
|
if not self.settings["cost_item"].CostQuantities:
|
||||||
return ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"cost.add_cost_item_quantity",
|
"cost.add_cost_item_quantity",
|
||||||
self.file,
|
self.file,
|
||||||
cost_item=self.settings["cost_item"],
|
cost_item=self.settings["cost_item"],
|
||||||
|
|||||||
Reference in New Issue
Block a user