diff --git a/src/ifcopenshell-python/ifcopenshell/api/control/assign_control.py b/src/ifcopenshell-python/ifcopenshell/api/control/assign_control.py index d06224ab40..f8cc67cef6 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/control/assign_control.py +++ b/src/ifcopenshell-python/ifcopenshell/api/control/assign_control.py @@ -26,9 +26,9 @@ class Usecase: controls = self.settings["relating_control"].Controls[0] if controls: - related_objects = list(controls.RelatedObjects) - related_objects.append(self.settings["related_object"]) - controls.RelatedObjects = related_objects + related_objects = set(controls.RelatedObjects) + related_objects.add(self.settings["related_object"]) + controls.RelatedObjects = list(related_objects) ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": controls}) else: controls = self.file.create_entity( diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item_quantity.py index b44282b2b1..dff2d825a0 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item_quantity.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item_quantity.py @@ -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