From 02379c5110c11e0ee6fe380d185cdc7dd1d7fdcb Mon Sep 17 00:00:00 2001 From: Sigma Dimensions <79010126+myoualid@users.noreply.github.com> Date: Wed, 31 Aug 2022 02:26:01 +0100 Subject: [PATCH] BBIM - New Sequence Toolkit Panel & new feature to highlight tasks for current selected object --- .../blenderbim/bim/module/sequence/__init__.py | 2 ++ .../blenderbim/bim/module/sequence/operator.py | 13 +++++++++++++ .../blenderbim/bim/module/sequence/ui.py | 13 +++++++++++++ src/blenderbim/blenderbim/core/sequence.py | 14 ++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/module/sequence/__init__.py b/src/blenderbim/blenderbim/bim/module/sequence/__init__.py index 7cef4a3ab3..662fa5b2d8 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/__init__.py @@ -20,6 +20,7 @@ import bpy from . import ui, prop, operator classes = ( + operator.HighlightProductRelatedTask, operator.ExpandAllTasks, operator.ContractAllTasks, operator.AddSummaryTask, @@ -127,6 +128,7 @@ classes = ( ui.BIM_UL_task_resources, ui.BIM_UL_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 ead12dae50..af673ad893 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/operator.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/operator.py @@ -1507,6 +1507,19 @@ class CalculateTaskDuration(bpy.types.Operator, tool.Ifc.Operator): def _execute(self, context): core.calculate_task_duration(tool.Ifc, tool.Sequence, task=tool.Ifc.get().by_id(self.task)) + + +class HighlightProductRelatedTask(bpy.types.Operator, tool.Ifc.Operator): + bl_idname = "bim.highlight_product_related_task" + bl_label = "Highlights the related task" + bl_options = {"REGISTER", "UNDO"} + bl_description = "Finds the related Task" + product_type: bpy.props.StringProperty() + + def _execute(self, context): + core.highlight_product_related_task(tool.Sequence, product_type=self.product_type) + + class ExpandAllTasks(bpy.types.Operator, tool.Ifc.Operator): bl_idname = "bim.expand_all_tasks" bl_label = "Expands all tasks" diff --git a/src/blenderbim/blenderbim/bim/module/sequence/ui.py b/src/blenderbim/blenderbim/bim/module/sequence/ui.py index 489684a8bf..161cd894f4 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/ui.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/ui.py @@ -732,3 +732,16 @@ class BIM_PT_work_calendars(Panel): def draw_editable_ui(self): draw_attributes(self.props.work_calendar_attributes, self.layout) + +class BIM_PT_SequenceToolKit(Panel): + bl_label = "Sequence Toolkit" + bl_idname = "BIM_PT_Sequence_toolkit" + bl_space_type = "VIEW_3D" + bl_region_type = "UI" + bl_category = "Sequence Toolkit" + + def draw(self, context): + row = self.layout.row() + row.operator("bim.highlight_product_related_task", text="Go to Input-related Task ", icon="STYLUS_PRESSURE").product_type = "Input" + row = self.layout.row() + row.operator("bim.highlight_product_related_task", text="Go to Output-related Task ",icon="STYLUS_PRESSURE").product_type = "Output" \ No newline at end of file diff --git a/src/blenderbim/blenderbim/core/sequence.py b/src/blenderbim/blenderbim/core/sequence.py index 3583ff0673..fc81c5ecbc 100644 --- a/src/blenderbim/blenderbim/core/sequence.py +++ b/src/blenderbim/blenderbim/core/sequence.py @@ -454,3 +454,17 @@ def calculate_task_duration(ifc, sequence, task=None): if work_schedule: sequence.create_task_tree(work_schedule) sequence.load_task_properties() + + +def highlight_product_related_task(sequence, product_type=None): + products = sequence.get_selected_products() + if products: + if product_type == "Output": + tasks = sequence.find_related_output_tasks(products[0]) + elif product_type == "Input": + tasks = sequence.find_related_input_tasks(products[0]) + for task in tasks: + work_schedule = sequence.get_work_schedule(task) + is_work_schedule_active = sequence.is_work_schedule_active(work_schedule) + if is_work_schedule_active: + sequence.highlight_task(task)