You can now store productivity rates and calculate resource work parametrically based on productivity

This commit is contained in:
Dion Moult
2021-08-25 18:15:19 +10:00
parent ae42d91c5c
commit 8c97b53bd2
8 changed files with 100 additions and 6 deletions
@@ -0,0 +1,13 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION((),'2;1');
FILE_NAME('EPset_Productivity.ifc','2020-01-01T00:00:00',(),(),'EPset_Productivity','EPset_Productivity',$);
FILE_SCHEMA(('IFC4'));
ENDSEC;
DATA;
#1=IFCPROPERTYSETTEMPLATE('24XxTA2ED4o83uiZBG59D_',$,'EPset_Productivity','',.PSET_TYPEDRIVENOVERRIDE.,'IfcConstructionEquipmentResource,IfcLaborResource',(#2,#3,#4));
#2=IFCSIMPLEPROPERTYTEMPLATE('3mL27FQ4X4MQn5fiGqIt8x',$,'BaseQuantityConsumed','',.P_SINGLEVALUE.,'IfcDuration',$,$,$,$,$,.READWRITE.);
#3=IFCSIMPLEPROPERTYTEMPLATE('1DdJt5_Ar2mR4UDpO$98Ws',$,'BaseQuantityProducedName','',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#4=IFCSIMPLEPROPERTYTEMPLATE('2OZPZ$Onb2gOvW20q7gacH',$,'BaseQuantityProducedValue','',.P_SINGLEVALUE.,'IfcReal',$,$,$,$,$,.READWRITE.);
ENDSEC;
END-ISO-10303-21;
@@ -36,6 +36,7 @@ classes = (
operator.EnableEditingResourceTime,
operator.EditResourceTime,
operator.DisableEditingResourceTime,
operator.CalculateResourceWork,
prop.Resource,
prop.BIMResourceProperties,
prop.BIMResourceTreeProperties,
@@ -371,3 +371,17 @@ class EditResourceTime(bpy.types.Operator):
return True
attributes[prop.name] = helper.parse_duration(prop.string_value)
return True
class CalculateResourceWork(bpy.types.Operator):
bl_idname = "bim.calculate_resource_work"
bl_label = "Calculate Resource Work"
bl_options = {"REGISTER", "UNDO"}
resource: bpy.props.IntProperty()
def execute(self, context):
self.file = IfcStore.get_file()
ifcopenshell.api.run("resource.calculate_resource_work", self.file, resource=self.file.by_id(self.resource))
Data.load(self.file)
bpy.ops.bim.load_resources()
return {"FINISHED"}
@@ -75,13 +75,21 @@ class BIM_PT_resources(Panel):
and Data.resources[self.tprops.resources[self.props.active_resource_index].ifc_definition_id]["type"]
!= "IfcSubContractResource"
):
ifc_definition_id = self.tprops.resources[self.props.active_resource_index].ifc_definition_id
row = self.layout.row(align=True)
for ifc_class, icon in icon_map.items():
label = ifc_class.replace("Ifc", "").replace("Construction", "").replace("Resource", "")
op = row.operator("bim.add_resource", text=label, icon=icon)
op.resource = self.tprops.resources[self.props.active_resource_index].ifc_definition_id
op.resource = ifc_definition_id
op.ifc_class = ifc_class
row = self.layout.row(align=True)
row.alignment = "RIGHT"
op = row.operator("bim.calculate_resource_work", text="", icon="TEMP")
op.resource = ifc_definition_id
self.layout.template_list(
"BIM_UL_resources",
"",
@@ -98,7 +98,7 @@ classes = (
operator.LoadTaskInputs,
operator.LoadTaskResources,
operator.LoadTaskOutputs,
operator.DeriveTaskDuration,
operator.CalculateTaskDuration,
prop.WorkPlan,
prop.BIMWorkPlanProperties,
prop.Task,
@@ -797,6 +797,7 @@ class AssignProduct(bpy.types.Operator):
related_object=self.file.by_id(self.task),
)
Data.load(self.file)
bpy.ops.bim.load_task_outputs()
return {"FINISHED"}
@@ -825,6 +826,7 @@ class UnassignProduct(bpy.types.Operator):
related_object=self.file.by_id(self.task),
)
Data.load(self.file)
bpy.ops.bim.load_task_outputs()
return {"FINISHED"}
@@ -2106,9 +2108,9 @@ class LoadTaskOutputs(bpy.types.Operator):
return {"FINISHED"}
class DeriveTaskDuration(bpy.types.Operator):
bl_idname = "bim.derive_task_duration"
bl_label = "Derive Task Duration"
class CalculateTaskDuration(bpy.types.Operator):
bl_idname = "bim.calculate_task_duration"
bl_label = "Calculate Task Duration"
bl_options = {"REGISTER", "UNDO"}
task: bpy.props.IntProperty()
@@ -371,7 +371,7 @@ class BIM_PT_task_icom(Panel):
row2 = col.row(align=True)
row2.label(text="Resources")
op = row2.operator("bim.derive_task_duration", text="", icon="TIME")
op = row2.operator("bim.calculate_task_duration", text="", icon="TEMP")
op.task = task.ifc_definition_id
total_resources = len(context.scene.BIMResourceTreeProperties.resources)