Cost quantities that are counting that have controlled products now automatically count the number of products for convenience

This commit is contained in:
Dion Moult
2021-04-27 14:45:14 +10:00
parent 9164a7bcc3
commit 56046dd6f9
2 changed files with 8 additions and 3 deletions
@@ -11,6 +11,11 @@ class Usecase:
def execute(self):
quantity = self.file.create_entity(self.settings["ifc_class"], Name="Unnamed")
quantity[3] = 0.0
# This is a bold assumption
# https://forums.buildingsmart.org/t/how-does-a-cost-item-know-that-it-is-counting-a-controlled-product/3564
if self.settings["ifc_class"] == "IfcQuantityCount" and self.settings["cost_item"].Controls:
for rel in self.settings["cost_item"].Controls:
quantity[3] += len(rel.RelatedObjects)
quantities = list(self.settings["cost_item"].CostQuantities or [])
quantities.append(quantity)
self.settings["cost_item"].CostQuantities = quantities