fix UI issue for loading product cost items

This commit is contained in:
Sigma Dimensions
2023-03-29 01:31:09 +00:00
parent 5b8b68457f
commit cc550c413b
2 changed files with 4 additions and 7 deletions
@@ -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"}
@@ -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",