mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 11:43:53 +00:00
You can now parametrically derive task durations from resource utilisation
This commit is contained in:
@@ -98,6 +98,7 @@ classes = (
|
||||
operator.LoadTaskInputs,
|
||||
operator.LoadTaskResources,
|
||||
operator.LoadTaskOutputs,
|
||||
operator.DeriveTaskDuration,
|
||||
prop.WorkPlan,
|
||||
prop.BIMWorkPlanProperties,
|
||||
prop.Task,
|
||||
|
||||
@@ -443,7 +443,7 @@ class AddTask(bpy.types.Operator):
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMWorkScheduleProperties
|
||||
self.file = IfcStore.get_file()
|
||||
ifcopenshell.api.run("sequence.add_task", self.file, **{"parent_task": self.file.by_id(self.task)})
|
||||
ifcopenshell.api.run("sequence.add_task", self.file, parent_task=self.file.by_id(self.task))
|
||||
Data.load(self.file)
|
||||
bpy.ops.bim.enable_editing_tasks(work_schedule=props.active_work_schedule_id)
|
||||
return {"FINISHED"}
|
||||
@@ -461,7 +461,7 @@ class AddSummaryTask(bpy.types.Operator):
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMWorkScheduleProperties
|
||||
self.file = IfcStore.get_file()
|
||||
ifcopenshell.api.run("sequence.add_task", self.file, **{"work_schedule": self.file.by_id(self.work_schedule)})
|
||||
ifcopenshell.api.run("sequence.add_task", self.file, work_schedule=self.file.by_id(self.work_schedule))
|
||||
Data.load(self.file)
|
||||
bpy.ops.bim.enable_editing_tasks(work_schedule=props.active_work_schedule_id)
|
||||
return {"FINISHED"}
|
||||
@@ -2098,9 +2098,24 @@ class LoadTaskOutputs(bpy.types.Operator):
|
||||
self.tprops = context.scene.BIMTaskTreeProperties
|
||||
ifc_definition_id = self.tprops.tasks[self.props.active_task_index].ifc_definition_id
|
||||
self.props.task_outputs.clear()
|
||||
for output_id in Data.tasks[ifc_definition_id]["outputs"]:
|
||||
for output_id in Data.tasks[ifc_definition_id]["Outputs"]:
|
||||
product = self.file.by_id(output_id)
|
||||
new = self.props.task_outputs.add()
|
||||
new.ifc_definition_id = output_id
|
||||
new.name = product.Name or "Unnamed"
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class DeriveTaskDuration(bpy.types.Operator):
|
||||
bl_idname = "bim.derive_task_duration"
|
||||
bl_label = "Derive Task Duration"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
task: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMWorkScheduleProperties
|
||||
self.file = IfcStore.get_file()
|
||||
ifcopenshell.api.run("sequence.calculate_task_duration", self.file, task=self.file.by_id(self.task))
|
||||
Data.load(self.file)
|
||||
bpy.ops.bim.enable_editing_tasks(work_schedule=props.active_work_schedule_id)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -363,9 +363,7 @@ class BIM_PT_task_icom(Panel):
|
||||
op.related_object = ""
|
||||
|
||||
row2 = col.row()
|
||||
row2.template_list(
|
||||
"BIM_UL_task_inputs", "", self.props, "task_inputs", self.props, "active_task_input_index"
|
||||
)
|
||||
row2.template_list("BIM_UL_task_inputs", "", self.props, "task_inputs", self.props, "active_task_input_index")
|
||||
|
||||
# Column2
|
||||
col = grid.column()
|
||||
@@ -373,17 +371,24 @@ 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.task = task.ifc_definition_id
|
||||
|
||||
total_resources = len(context.scene.BIMResourceTreeProperties.resources)
|
||||
if total_resources and context.scene.BIMResourceProperties.active_resource_index < total_resources:
|
||||
resource_id = context.scene.BIMResourceTreeProperties.resources[context.scene.BIMResourceProperties.active_resource_index].ifc_definition_id
|
||||
op = row2.operator("bim.assign_process", icon="ADD", text="")
|
||||
op.task = task.ifc_definition_id
|
||||
op.related_object_type = "RESOURCE"
|
||||
op.resource = resource_id
|
||||
op.resource = context.scene.BIMResourceTreeProperties.resources[
|
||||
context.scene.BIMResourceProperties.active_resource_index
|
||||
].ifc_definition_id
|
||||
|
||||
total_task_resources = len(self.props.task_resources)
|
||||
if total_task_resources and self.props.active_task_resource_index < total_task_resources:
|
||||
op = row2.operator("bim.unassign_process", icon="REMOVE", text="")
|
||||
op.task = task.ifc_definition_id
|
||||
op.related_object_type = "RESOURCE"
|
||||
op.resource = resource_id
|
||||
op.resource = self.props.task_resources[self.props.active_task_resource_index].ifc_definition_id
|
||||
|
||||
row2 = col.row()
|
||||
row2.template_list(
|
||||
@@ -430,7 +435,7 @@ class BIM_UL_task_inputs(UIList):
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
row.prop(item, "name", emboss=False, text="")
|
||||
#row.operator("bim.remove_task_column", text="", icon="X").name = item.name
|
||||
# row.operator("bim.remove_task_column", text="", icon="X").name = item.name
|
||||
|
||||
|
||||
class BIM_UL_task_resources(UIList):
|
||||
|
||||
Reference in New Issue
Block a user