diff --git a/src/blenderbim/blenderbim/bim/module/cost/operator.py b/src/blenderbim/blenderbim/bim/module/cost/operator.py index 37019a692c..fc92f99292 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/operator.py +++ b/src/blenderbim/blenderbim/bim/module/cost/operator.py @@ -341,11 +341,19 @@ class UnassignCostItemProduct(bpy.types.Operator): def _execute(self, context): self.file = IfcStore.get_file() + if self.related_object: + products = [self.file.by_id(self.related_object)] + else: + products = [ + self.file.by_id(o.BIMObjectProperties.ifc_definition_id) + for o in bpy.context.selected_objects + if o.BIMObjectProperties.ifc_definition_id + ] ifcopenshell.api.run( "cost.unassign_cost_item_product", self.file, cost_item=self.file.by_id(self.cost_item), - products=[self.file.by_id(self.related_object)], + products=products, ) Data.load(self.file) bpy.ops.bim.load_cost_item_quantities() diff --git a/src/blenderbim/blenderbim/bim/module/cost/ui.py b/src/blenderbim/blenderbim/bim/module/cost/ui.py index 731e2812cd..46779e868e 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/ui.py +++ b/src/blenderbim/blenderbim/bim/module/cost/ui.py @@ -309,11 +309,14 @@ class BIM_PT_cost_item_quantities(Panel): "active_cost_item_product_index", ) - row = self.layout.row(align=True) + row = self.layout.row() row2 = row.row(align=True) row2.prop(self.props, "quantity_names", text="") - op = row.operator("bim.assign_cost_item_product", text="", icon="ADD") + op = row2.operator("bim.unassign_cost_item_product", text="", icon="REMOVE") + op.cost_item = cost_item.ifc_definition_id + op.related_object = 0 + op = row2.operator("bim.assign_cost_item_product", text="", icon="ADD") op.cost_item = cost_item.ifc_definition_id row2 = row.row(align=True)