You can now calculate costs from direct resources and indirect task-based resources

This commit is contained in:
Dion Moult
2021-08-28 18:21:22 +10:00
parent faaeef92de
commit c726e8feb9
4 changed files with 78 additions and 0 deletions
@@ -65,6 +65,7 @@ classes = (
operator.LoadScheduleOfRates,
operator.ExpandCostItemRate,
operator.ContractCostItemRate,
operator.CalculateCostItemResourceValue,
prop.CostItem,
prop.CostItemQuantity,
prop.CostItemType,
@@ -1054,3 +1054,21 @@ class ContractCostItemRate(bpy.types.Operator):
props.contracted_cost_item_rates = json.dumps(contracted_cost_item_rates)
bpy.ops.bim.load_schedule_of_rates(cost_schedule=int(props.schedule_of_rates))
return {"FINISHED"}
class CalculateCostItemResourceValue(bpy.types.Operator):
bl_idname = "bim.calculate_cost_item_resource_value"
bl_label = "Calculate Cost Item Resource Value"
bl_options = {"REGISTER", "UNDO"}
cost_item: bpy.props.IntProperty()
def execute(self, context):
return IfcStore.execute_ifc_operator(self, context)
def _execute(self, context):
self.file = IfcStore.get_file()
ifcopenshell.api.run(
"cost.calculate_cost_item_resource_value", self.file, cost_item=self.file.by_id(self.cost_item)
)
Data.load(self.file)
return {"FINISHED"}
@@ -432,6 +432,9 @@ class BIM_PT_cost_item_quantities(Panel):
row2 = col.row(align=True)
row2.label(text="Resources")
op = row2.operator("bim.calculate_cost_item_resource_value", text="", icon="DISC")
op.cost_item = cost_item.ifc_definition_id
rtprops = context.scene.BIMResourceTreeProperties
rprops = context.scene.BIMResourceProperties
if rtprops.resources and rprops.active_resource_index < len(rtprops.resources):