From 95de43f5b66833d89e54cb5ff6a90016d26a8a58 Mon Sep 17 00:00:00 2001 From: "Sigma Dimensions (Yass)" <79010126+myoualid@users.noreply.github.com> Date: Tue, 22 Aug 2023 20:03:09 +0100 Subject: [PATCH] forgotten bits and bobs + run black --- src/blenderbim/blenderbim/core/tool.py | 1 + src/blenderbim/blenderbim/tool/sequence.py | 25 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/blenderbim/blenderbim/core/tool.py b/src/blenderbim/blenderbim/core/tool.py index 452c84d70f..4b75600581 100644 --- a/src/blenderbim/blenderbim/core/tool.py +++ b/src/blenderbim/blenderbim/core/tool.py @@ -766,6 +766,7 @@ class Sequence: def show_snapshot(cls, product_states): pass def update_task_ICOM(cls, task): pass def update_visualisation_date(cls, start_date, finish_date): pass + def refresh_task_resources(cls): pass @interface diff --git a/src/blenderbim/blenderbim/tool/sequence.py b/src/blenderbim/blenderbim/tool/sequence.py index ebd84b656c..0706103f2b 100644 --- a/src/blenderbim/blenderbim/tool/sequence.py +++ b/src/blenderbim/blenderbim/tool/sequence.py @@ -198,8 +198,12 @@ class Sequence(blenderbim.core.tool.Sequence): item.name = task.Name or "Unnamed" item.identification = task.Identification or "XXX" if props.highlighted_task_id: - item.is_predecessor = props.highlighted_task_id in [rel.RelatedProcess.id() for rel in task.IsPredecessorTo] - item.is_successor = props.highlighted_task_id in [rel.RelatingProcess.id() for rel in task.IsSuccessorFrom] + item.is_predecessor = props.highlighted_task_id in [ + rel.RelatedProcess.id() for rel in task.IsPredecessorTo + ] + item.is_successor = props.highlighted_task_id in [ + rel.RelatingProcess.id() for rel in task.IsSuccessorFrom + ] calendar = ifcopenshell.util.sequence.derive_calendar(task) if task.HasAssignments: for rel in task.HasAssignments: @@ -466,9 +470,11 @@ class Sequence(blenderbim.core.tool.Sequence): @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) + tasks = bpy.context.scene.BIMTaskTreeProperties.tasks + if len(tasks) and len(tasks) > bpy.context.scene.BIMWorkScheduleProperties.active_task_index: + return tool.Ifc.get().by_id( + tasks[bpy.context.scene.BIMWorkScheduleProperties.active_task_index].ifc_definition_id + ) @classmethod def get_direct_nested_tasks(cls, task): @@ -1667,4 +1673,11 @@ class Sequence(blenderbim.core.tool.Sequence): resources = cls.get_task_resources(task) cls.load_task_inputs(inputs) cls.load_task_outputs(outputs) - cls.load_task_resources(resources) \ No newline at end of file + cls.load_task_resources(resources) + + @classmethod + def refresh_task_resources(cls): + task = cls.get_highlighted_task() + if not task: + return + cls.load_task_resources(cls.get_task_resources(task))