diff --git a/src/blenderbim/blenderbim/bim/module/cost/prop.py b/src/blenderbim/blenderbim/bim/module/cost/prop.py index ec88a54d39..4b65b1ea9a 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/prop.py +++ b/src/blenderbim/blenderbim/bim/module/cost/prop.py @@ -75,7 +75,7 @@ def update_active_cost_item_index(self, context): if schedule.PredefinedType == "SCHEDULEOFRATES": tool.Cost.load_cost_item_types() else: - tool.Cost.load_cost_item_quantities(cost_item=tool.Cost.get_highlighted_cost_item()) + tool.Cost.load_cost_item_quantities() CostClassificationsData.load() diff --git a/src/blenderbim/blenderbim/bim/module/cost/ui.py b/src/blenderbim/blenderbim/bim/module/cost/ui.py index 545a39eb59..076df54d3b 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/ui.py +++ b/src/blenderbim/blenderbim/bim/module/cost/ui.py @@ -61,12 +61,11 @@ class BIM_PT_cost_schedules(Panel): row.label(text=cost_schedule["name"], icon="LINENUMBERS_ON") if self.props.active_cost_schedule_id and self.props.active_cost_schedule_id == cost_schedule["id"]: - op = row.operator("bim.select_cost_schedule_products", icon="RESTRICT_SELECT_OFF", text="") + op = row.operator("bim.select_cost_schedule_products", icon="RESTRICT_SELECT_OFF", text="Assigned") op.cost_schedule = cost_schedule["id"] - row.prop(self.props, "should_show_column_ui", text="", icon="SHORTDISPLAY") - row.operator("bim.select_unassigned_products", icon="RESTRICT_SELECT_OFF", text="Unassigned") + row.prop(self.props, "should_show_column_ui", text="", icon="SHORTDISPLAY") if self.props.is_editing == "COST_SCHEDULE_ATTRIBUTES": row.operator("bim.edit_cost_schedule", text="", icon="CHECKMARK") elif self.props.is_editing == "COST_ITEMS": diff --git a/src/blenderbim/blenderbim/core/cost.py b/src/blenderbim/blenderbim/core/cost.py index 3b8822c84a..383ab46009 100644 --- a/src/blenderbim/blenderbim/core/cost.py +++ b/src/blenderbim/blenderbim/core/cost.py @@ -106,15 +106,10 @@ def assign_cost_item_quantity(ifc, cost, cost_item, related_object_type, prop_na products = cost.get_products(related_object_type) if products: ifc.run("cost.assign_cost_item_quantity", cost_item=cost_item, products=products, prop_name=prop_name) - cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PRODUCT") - cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PROCESS") - cost.load_cost_item_quantity_assignments(cost_item, related_object_type="RESOURCE") + cost.load_cost_item_quantity_assignments(cost_item, related_object_type=related_object_type) def load_cost_item_quantities(cost): - cost_item = cost.get_highlighted_cost_item() - cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PRODUCT") - cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PROCESS") - cost.load_cost_item_quantity_assignments(cost_item, related_object_type="RESOURCE") + cost.load_cost_item_quantities() def load_cost_item_element_quantities(cost): cost_item = cost.get_highlighted_cost_item() @@ -136,9 +131,7 @@ def load_schedule_of_rates(cost, schedule_of_rates): def unassign_cost_item_quantity(ifc, cost, cost_item, products): ifc.run("cost.unassign_cost_item_quantity", cost_item=cost_item, products=products) - cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PRODUCT") - cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PROCESS") - cost.load_cost_item_quantity_assignments(cost_item, related_object_type="RESOURCE") + cost.load_cost_item_quantities() def enable_editing_cost_item_quantities(cost, cost_item): cost.enable_editing_cost_item_quantities(cost_item) @@ -163,10 +156,7 @@ def edit_cost_item_quantity(ifc, cost, physical_quantity): attributes = cost.get_cost_item_quantity_attributes() ifc.run("cost.edit_cost_item_quantity", physical_quantity=physical_quantity, attributes=attributes) cost.disable_editing_cost_item_quantity() - #TODO: REVIEW usefulness - cost.load_cost_item_quantity_assignments(cost.get_highlighted_cost_item(), related_object_type="PRODUCT") - cost.load_cost_item_quantity_assignments(cost.get_highlighted_cost_item(), related_object_type="PROCESS") - cost.load_cost_item_quantity_assignments(cost.get_highlighted_cost_item(), related_object_type="RESOURCE") + cost.load_cost_item_quantities() def add_cost_value(ifc, cost, parent, cost_type, cost_category): value = ifc.run("cost.add_cost_value", parent=parent) diff --git a/src/blenderbim/blenderbim/tool/cost.py b/src/blenderbim/blenderbim/tool/cost.py index e6bee05b4f..e7bcb864ca 100644 --- a/src/blenderbim/blenderbim/tool/cost.py +++ b/src/blenderbim/blenderbim/tool/cost.py @@ -82,14 +82,14 @@ class Cost(blenderbim.core.tool.Cost): props = bpy.context.scene.BIMCostProperties if not hasattr(cls, "contracted_cost_items"): cls.contracted_cost_items = json.loads(props.contracted_cost_items) - cls.contracted_cost_items.remove(cost_item.id()) - props.contracted_cost_items = json.dumps(cls.contracted_cost_items) + if cost_item.id() in cls.contracted_cost_items: + cls.contracted_cost_items.remove(cost_item.id()) + props.contracted_cost_items = json.dumps(cls.contracted_cost_items) @classmethod def expand_cost_items(cls): props = bpy.context.scene.BIMCostProperties - if not hasattr(cls, "contracted_cost_items"): - cls.contracted_cost_items = json.loads(props.contracted_cost_items) + cls.contracted_cost_items = json.loads(props.contracted_cost_items) for cost_item in props.cost_items: if cost_item.ifc_definition_id in cls.contracted_cost_items: cls.contracted_cost_items.remove(cost_item.ifc_definition_id) @@ -630,3 +630,11 @@ class Cost(blenderbim.core.tool.Cost): def disable_editing_cost_item_parent(cls): bpy.context.scene.BIMCostProperties.active_cost_item_id = 0 bpy.context.scene.BIMCostProperties.change_cost_item_parent = False + + @classmethod + def load_cost_item_quantities(cls, cost_item=None): + if not cost_item: + cost_item = tool.Cost.get_highlighted_cost_item() + tool.Cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PRODUCT") + tool.Cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PROCESS") + tool.Cost.load_cost_item_quantity_assignments(cost_item, related_object_type="RESOURCE") \ No newline at end of file