From cc550c413ba067c99b1d2847184ee489d30506c4 Mon Sep 17 00:00:00 2001 From: Sigma Dimensions <79010126+myoualid@users.noreply.github.com> Date: Wed, 29 Mar 2023 01:31:09 +0000 Subject: [PATCH] fix UI issue for loading product cost items --- src/blenderbim/blenderbim/bim/module/cost/operator.py | 5 +++-- src/blenderbim/blenderbim/bim/module/cost/ui.py | 6 +----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/cost/operator.py b/src/blenderbim/blenderbim/bim/module/cost/operator.py index 579e89653b..fbff8b4ed5 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/operator.py +++ b/src/blenderbim/blenderbim/bim/module/cost/operator.py @@ -656,18 +656,19 @@ class LoadProductCostItems(bpy.types.Operator): bl_idname = "bim.load_product_cost_items" bl_label = "Get Product Cost Assignments" bl_options = {"REGISTER", "UNDO"} - product: bpy.props.IntProperty() @classmethod def poll(cls, context): if not tool.Ifc.get(): return False + if not context.active_object: + return False if not context.active_object.BIMObjectProperties.ifc_definition_id: return False return True def execute(self, context): - core.load_product_cost_items(tool.Cost, product=tool.Ifc.get().by_id(self.product)) + core.load_product_cost_items(tool.Cost, product=tool.Ifc.get().by_id(context.active_object.BIMObjectProperties.ifc_definition_id)) return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/bim/module/cost/ui.py b/src/blenderbim/blenderbim/bim/module/cost/ui.py index ef26719702..07b8c79580 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/ui.py +++ b/src/blenderbim/blenderbim/bim/module/cost/ui.py @@ -643,10 +643,6 @@ class BIM_UL_cost_item_quantities(UIList): class BIM_UL_product_cost_items(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): - props = context.scene.BIMCostProperties - oprops = context.active_object.BIMObjectProperties - cost_item = props.cost_items[props.active_cost_item_index] - if item: row = layout.row(align=True) op = row.operator("bim.highlight_product_cost_item", text="", icon="STYLUS_PRESSURE") @@ -667,7 +663,7 @@ class BIM_PT_Costing_Tools(Panel): row = self.layout.row() row.operator( "bim.load_product_cost_items", icon="FILE_REFRESH" - ).product = context.active_object.BIMObjectProperties.ifc_definition_id + ) row = self.layout.row() row.template_list( "BIM_UL_product_cost_items",