diff --git a/src/blenderbim/blenderbim/bim/module/sequence/__init__.py b/src/blenderbim/blenderbim/bim/module/sequence/__init__.py index 662fa5b2d8..a6684f904a 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/__init__.py @@ -83,6 +83,7 @@ classes = ( operator.ImportPP, operator.LoadTaskInputs, operator.LoadTaskOutputs, + operator.LoadNestedTasksOutputs, operator.LoadTaskProperties, operator.LoadTaskResources, operator.RecalculateSchedule, @@ -127,6 +128,7 @@ classes = ( ui.BIM_UL_task_inputs, ui.BIM_UL_task_resources, ui.BIM_UL_task_outputs, + ui.BIM_UL_nested_task_outputs, ui.BIM_UL_tasks, ui.BIM_PT_SequenceToolKit, ) diff --git a/src/blenderbim/blenderbim/bim/module/sequence/operator.py b/src/blenderbim/blenderbim/bim/module/sequence/operator.py index 43722ee9a0..d53e029343 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/operator.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/operator.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with BlenderBIM Add-on. If not, see . -import re import os import bpy import json @@ -25,15 +24,10 @@ import calendar import isodate import pystache import webbrowser -import ifcopenshell.api -import ifcopenshell.util.date -import ifcopenshell.util.sequence import blenderbim.core.sequence as core import blenderbim.tool as tool -import blenderbim.bim.helper import blenderbim.bim.module.sequence.helper as helper from datetime import datetime -from datetime import timedelta from dateutil import parser, relativedelta from blenderbim.bim.ifc import IfcStore from bpy_extras.io_utils import ImportHelper @@ -1022,10 +1016,10 @@ class SelectTaskRelatedProducts(bpy.types.Operator, tool.Ifc.Operator): bl_label = "Select All Output Products" bl_options = {"REGISTER", "UNDO"} task: bpy.props.IntProperty() + type: bpy.props.StringProperty() def _execute(self, context): - core.select_task_outputs(tool.Ifc, tool.Sequence, task=tool.Ifc.get().by_id(self.task)) - + core.select_task_outputs(tool.Ifc, tool.Sequence, task=tool.Ifc.get().by_id(self.task), type=self.type) class SelectTaskRelatedInputs(bpy.types.Operator, tool.Ifc.Operator): bl_idname = "bim.select_task_related_inputs" @@ -1510,6 +1504,15 @@ class LoadTaskOutputs(bpy.types.Operator): def execute(self, context): core.load_task_outputs(tool.Sequence) return {"FINISHED"} + +class LoadNestedTasksOutputs(bpy.types.Operator): + bl_idname = "bim.load_nested_tasks_outputs" + bl_label = "Load Task Outputs" + bl_options = {"REGISTER", "UNDO"} + + def execute(self, context): + core.load_nested_tasks_outputs(tool.Sequence) + return {"FINISHED"} class CalculateTaskDuration(bpy.types.Operator, tool.Ifc.Operator): diff --git a/src/blenderbim/blenderbim/bim/module/sequence/prop.py b/src/blenderbim/blenderbim/bim/module/sequence/prop.py index 78eb025548..3cb8ec1885 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/prop.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/prop.py @@ -90,6 +90,7 @@ def update_active_task_index(self, context): bpy.ops.bim.load_task_inputs() bpy.ops.bim.load_task_resources() bpy.ops.bim.load_task_outputs() + bpy.ops.bim.load_nested_tasks_outputs() blenderbim.bim.module.pset.data.refresh() @@ -350,7 +351,8 @@ class BIMWorkScheduleProperties(PropertyGroup): active_task_input_index: IntProperty(name="Active Task Input Index") task_outputs: CollectionProperty(name="Task Outputs", type=TaskProduct) active_task_output_index: IntProperty(name="Active Task Output Index") - + nested_task_outputs: CollectionProperty(name="Nested Task Outputs", type=TaskProduct) + active_nested_task_output_index: IntProperty(name="Active Nested Tasks Output Index") class BIMDuration(PropertyGroup): duration_days: IntProperty(name="Days ") diff --git a/src/blenderbim/blenderbim/bim/module/sequence/ui.py b/src/blenderbim/blenderbim/bim/module/sequence/ui.py index 7095f6837c..21e81dd5ea 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/ui.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/ui.py @@ -427,7 +427,7 @@ class BIM_PT_task_icom(Panel): col = grid.column() row2 = col.row(align=True) - row2.label(text="Outputs") + row2.label(text="Task Outputs") total_task_outputs = len(self.props.task_outputs) if context.selected_objects: @@ -440,14 +440,23 @@ class BIM_PT_task_icom(Panel): output_id = self.props.task_outputs[self.props.active_task_output_index].ifc_definition_id op.relating_product = output_id - op = row2.operator("bim.select_task_related_products", icon="RESTRICT_SELECT_OFF", text="") + op = row2.operator("bim.select_task_related_products", icon="RESTRICT_SELECT_OFF", text="Select") op.task = task.ifc_definition_id - + op.type = 'CURRENT_TASK' row2 = col.row() row2.template_list( "BIM_UL_task_outputs", "", self.props, "task_outputs", self.props, "active_task_output_index" ) - + # Column3 // Row3 + row3 = col.row() + row3.label(text="Nested Tasks Outputs") + op = row3.operator("bim.select_task_related_products", icon="RESTRICT_SELECT_OFF", text="Select") + op.type = 'NESTED_TASKS' + op.task = task.ifc_definition_id + row3 = col.row() + row3.template_list( + "BIM_UL_nested_task_outputs", "", self.props, "nested_task_outputs", self.props, "active_nested_task_output_index" + ) class BIM_UL_task_columns(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): @@ -462,7 +471,6 @@ class BIM_UL_task_columns(UIList): class BIM_UL_task_inputs(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): - props = context.scene.BIMWorkScheduleProperties if item: row = layout.row(align=True) row.prop(item, "name", emboss=False, text="") @@ -471,7 +479,6 @@ class BIM_UL_task_inputs(UIList): class BIM_UL_task_resources(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): - props = context.scene.BIMWorkScheduleProperties if item: row = layout.row(align=True) row.prop(item, "name", emboss=False, text="") @@ -479,7 +486,13 @@ class BIM_UL_task_resources(UIList): class BIM_UL_task_outputs(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): - props = context.scene.BIMWorkScheduleProperties + if item: + row = layout.row(align=True) + row.prop(item, "name", emboss=False, text="") + + +class BIM_UL_nested_task_outputs(UIList): + def draw_item(self, context, layout, data, item, icon, active_data, active_propname): if item: row = layout.row(align=True) row.prop(item, "name", emboss=False, text="") diff --git a/src/blenderbim/blenderbim/core/sequence.py b/src/blenderbim/blenderbim/core/sequence.py index 4ba2fe0841..244fa42fc1 100644 --- a/src/blenderbim/blenderbim/core/sequence.py +++ b/src/blenderbim/blenderbim/core/sequence.py @@ -267,7 +267,12 @@ def load_task_outputs(sequence): outputs = sequence.get_task_outputs(task) sequence.load_task_outputs(outputs) - +def load_nested_tasks_outputs(sequence): + task = sequence.get_highlighted_task() + nested_tasks = sequence.get_nested_tasks(task) + outputs = sequence.get_nested_tasks_outputs(nested_tasks) + sequence.load_nested_tasks_outputs(outputs) + def load_task_inputs(sequence): task = sequence.get_highlighted_task() inputs = sequence.get_task_inputs(task) @@ -423,8 +428,12 @@ def disable_editing_rel_sequence(sequence): sequence.disable_editing_rel_sequence() -def select_task_outputs(ifc, sequence, task=None): - outputs = sequence.get_task_outputs(task) +def select_task_outputs(ifc, sequence, task=None, type=None): + if type == 'CURRENT_TASK': + outputs = sequence.get_task_outputs(task) + elif type == 'NESTED_TASKS': + tasks = sequence.get_nested_tasks(task) + outputs = sequence.get_nested_tasks_outputs(tasks) sequence.select_task_products(outputs) diff --git a/src/blenderbim/blenderbim/core/tool.py b/src/blenderbim/blenderbim/core/tool.py index 2a82947dba..536e1b0b07 100644 --- a/src/blenderbim/blenderbim/core/tool.py +++ b/src/blenderbim/blenderbim/core/tool.py @@ -487,7 +487,9 @@ class Sequence: def get_active_work_schedule_id(cls): pass def get_selected_resource(cls): pass def expand_task(cls, task): pass + def expand_all_tasks(cls): pass def contract_task(cls, task): pass + def contract_all_tasks(cls): pass def disable_work_schedule(cls): pass def disable_selecting_deleted_task(cls): pass def get_checked_tasks(cls): pass @@ -507,8 +509,10 @@ class Sequence: def get_task_inputs(cls, task): pass def load_task_inputs(cls, inputs): pass def load_task_outputs(cls, outputs): pass + def load_nested_task_outputs(cls, outputs): pass def get_highlighted_task(cls): pass def get_task_outputs(cls, task): pass + def get_nested_task_outputs(cls, tasks): pass def get_task_resources(cls, task):pass def enable_editing_work_calendar_times(cls, work_calendar): pass def load_work_calendar_attributes(cls, work_calendar): pass diff --git a/src/blenderbim/blenderbim/tool/sequence.py b/src/blenderbim/blenderbim/tool/sequence.py index 8c0664b3b2..1bc7bfa736 100644 --- a/src/blenderbim/blenderbim/tool/sequence.py +++ b/src/blenderbim/blenderbim/tool/sequence.py @@ -461,14 +461,33 @@ class Sequence(blenderbim.core.tool.Sequence): new.name = output.Name or "Unnamed" @classmethod + def load_nested_tasks_outputs(cls, outputs): + props = bpy.context.scene.BIMWorkScheduleProperties + props.nested_task_outputs.clear() + if outputs: + for output in outputs: + new = props.nested_task_outputs.add() + new.ifc_definition_id = output.id() + new.name = output.Name or "Unnamed" + @classmethod def get_highlighted_task(cls): props = bpy.context.scene.BIMWorkScheduleProperties task_props = bpy.context.scene.BIMTaskTreeProperties return tool.Ifc.get().by_id(task_props.tasks[props.active_task_index].ifc_definition_id) + @classmethod + def get_nested_tasks(cls, task): + return helper.get_nested_tasks(task) + @classmethod def get_task_outputs(cls, task): return [rel.RelatingProduct for rel in task.HasAssignments if rel.is_a("IfcRelAssignsToProduct")] + @classmethod + def get_nested_tasks_outputs(cls, tasks): + outputs = [] + for subtask in tasks: + [outputs.append(rel.RelatingProduct) for rel in subtask.HasAssignments if rel.is_a("IfcRelAssignsToProduct")] + return outputs @classmethod def get_task_resources(cls, task):