BBIM - temp fix to refresh cost items products' quantities UI, when qto is edited

This commit is contained in:
Sigma Dimensions
2022-09-09 11:43:28 +01:00
parent 87f0475b99
commit cbe944d030
3 changed files with 23 additions and 15 deletions
@@ -923,24 +923,26 @@ class LoadCostItemQuantities(bpy.types.Operator):
def execute(self, context): def execute(self, context):
self.props = context.scene.BIMCostProperties self.props = context.scene.BIMCostProperties
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
Data.load(self.file)
self.props.cost_item_products.clear() self.props.cost_item_products.clear()
self.props.cost_item_processes.clear() self.props.cost_item_processes.clear()
self.props.cost_item_resources.clear() self.props.cost_item_resources.clear()
ifc_definition_id = self.props.cost_items[self.props.active_cost_item_index].ifc_definition_id if self.props.active_cost_item_index:
for control_id, quantity_ids in Data.cost_items[ifc_definition_id]["Controls"].items(): ifc_definition_id = self.props.cost_items[self.props.active_cost_item_index].ifc_definition_id
related_object = self.file.by_id(control_id) for control_id, quantity_ids in Data.cost_items[ifc_definition_id]["Controls"].items() or {}:
if related_object.is_a("IfcProduct"): related_object = self.file.by_id(control_id)
new = self.props.cost_item_products.add() if related_object.is_a("IfcProduct"):
elif related_object.is_a("IfcProcess"): new = self.props.cost_item_products.add()
new = self.props.cost_item_processes.add() elif related_object.is_a("IfcProcess"):
elif related_object.is_a("IfcResource"): new = self.props.cost_item_processes.add()
new = self.props.cost_item_resources.add() elif related_object.is_a("IfcResource"):
new.ifc_definition_id = control_id new = self.props.cost_item_resources.add()
new.name = related_object.Name or "Unnamed" new.ifc_definition_id = control_id
total_quantity = 0 new.name = related_object.Name or "Unnamed"
for quantity_id in quantity_ids: total_quantity = 0
total_quantity += self.file.by_id(quantity_id)[3] for quantity_id in quantity_ids:
new.total_quantity = total_quantity total_quantity += self.file.by_id(quantity_id)[3]
new.total_quantity = total_quantity
return {"FINISHED"} return {"FINISHED"}
@@ -343,6 +343,11 @@ class BIM_PT_cost_item_quantities(Panel):
return False return False
def draw(self, context): def draw(self, context):
if not Data.is_loaded:
Data.load(IfcStore.get_file())
if not UnitData.is_loaded:
UnitData.load(IfcStore.get_file())
self.props = context.scene.BIMCostProperties self.props = context.scene.BIMCostProperties
cost_item = self.props.cost_items[self.props.active_cost_item_index] cost_item = self.props.cost_items[self.props.active_cost_item_index]
@@ -261,6 +261,7 @@ class EditPset(bpy.types.Operator, Operator):
}, },
) )
CostData.purge() CostData.purge()
bpy.ops.bim.load_cost_item_quantities()
Data.load(IfcStore.get_file(), ifc_definition_id) Data.load(IfcStore.get_file(), ifc_definition_id)
bpy.ops.bim.disable_pset_editing(obj=self.obj, obj_type=self.obj_type) bpy.ops.bim.disable_pset_editing(obj=self.obj, obj_type=self.obj_type)