diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/unassign_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/unassign_cost_item_quantity.py index e4b48bafa0..967cec4162 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/unassign_cost_item_quantity.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/unassign_cost_item_quantity.py @@ -98,4 +98,7 @@ class Usecase: count = 0 for rel in self.settings["cost_item"].Controls: count += len(rel.RelatedObjects) - quantity[3] = count + if count: + quantity[3] = count + else: + self.file.remove(quantity)