From 5dfbbb8d96c1542dda0fa17d021fcc3320b119e3 Mon Sep 17 00:00:00 2001 From: "Sigma Dimensions (Yass)" <79010126+myoualid@users.noreply.github.com> Date: Tue, 26 Sep 2023 16:42:35 +0100 Subject: [PATCH] maintain tasks bar visual property state when tasks properties are reloaded --- .../blenderbim/bim/module/sequence/prop.py | 11 ++++++- src/blenderbim/blenderbim/tool/sequence.py | 32 ++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/sequence/prop.py b/src/blenderbim/blenderbim/bim/module/sequence/prop.py index 30dc776cf7..add76f452e 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/prop.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/prop.py @@ -347,6 +347,14 @@ def updateAssignedResourceUsage(self, context): blenderbim.bim.module.pset.data.refresh() +def update_task_bar_list(self, context): + if not context.scene.BIMWorkScheduleProperties.is_task_update_enabled: + return + if self.has_bar_visual: + tool.Sequence.add_task_bar(self.ifc_definition_id) + else: + tool.Sequence.remove_task_bar(self.ifc_definition_id) + class Task(PropertyGroup): name: StringProperty(name="Name", update=updateTaskName) identification: StringProperty(name="Identification", update=updateTaskIdentification) @@ -354,7 +362,7 @@ class Task(PropertyGroup): has_children: BoolProperty(name="Has Children") is_selected: BoolProperty(name="Is Selected") is_expanded: BoolProperty(name="Is Expanded") - has_bar_visual: BoolProperty(name="Show Task Bar Animation", default=False) + has_bar_visual: BoolProperty(name="Show Task Bar Animation", default=False, update=update_task_bar_list) level_index: IntProperty(name="Level Index") duration: StringProperty(name="Duration", update=updateTaskDuration) start: StringProperty(name="Start", update=updateTaskTimeStart) @@ -456,6 +464,7 @@ class BIMWorkScheduleProperties(PropertyGroup): active_task_time_id: IntProperty(name="Active Task Time Id") task_time_attributes: CollectionProperty(name="Task Time Attributes", type=Attribute) contracted_tasks: StringProperty(name="Contracted Task Items", default="[]") + task_bars: StringProperty(name="Checked Task Items", default="[]") is_task_update_enabled: BoolProperty(name="Is Task Update Enabled", default=True) editing_sequence_type: StringProperty(name="Editing Sequence Type") active_sequence_id: IntProperty(name="Active Sequence Id") diff --git a/src/blenderbim/blenderbim/tool/sequence.py b/src/blenderbim/blenderbim/tool/sequence.py index d6767954d8..ff28484fb1 100644 --- a/src/blenderbim/blenderbim/tool/sequence.py +++ b/src/blenderbim/blenderbim/tool/sequence.py @@ -191,12 +191,14 @@ class Sequence(blenderbim.core.tool.Sequence): props = bpy.context.scene.BIMWorkScheduleProperties task_props = bpy.context.scene.BIMTaskTreeProperties + tasks_with_visual_bar = cls.get_task_bar_list() props.is_task_update_enabled = False for item in task_props.tasks: task = tool.Ifc.get().by_id(item.ifc_definition_id) item.name = task.Name or "Unnamed" item.identification = task.Identification or "XXX" + item.has_bar_visual = item.ifc_definition_id in tasks_with_visual_bar if props.highlighted_task_id: item.is_predecessor = props.highlighted_task_id in [ rel.RelatedProcess.id() for rel in task.IsPredecessorTo @@ -796,10 +798,9 @@ class Sequence(blenderbim.core.tool.Sequence): @classmethod def get_animation_bar_tasks(cls): return [ - tool.Ifc.get().by_id(item.ifc_definition_id) - for item in bpy.context.scene.BIMTaskTreeProperties.tasks - if item.has_bar_visual - ] or [] + tool.Ifc.get().by_id(task_id) + for task_id in cls.get_task_bar_list() + ] @classmethod def create_bars(cls, tasks): @@ -1289,6 +1290,12 @@ class Sequence(blenderbim.core.tool.Sequence): obj.hide_viewport = False obj.hide_render = False + @classmethod + def hide_object(cls, obj): + if obj.visible_get(): + obj.hide_viewport = True + obj.hide_render = True + @classmethod def clear_objects_animation(cls, include_blender_objects=True): for obj in bpy.data.objects: @@ -1676,3 +1683,20 @@ class Sequence(blenderbim.core.tool.Sequence): if task.TaskTime and task.TaskTime.ScheduleDuration: return True return False + + @classmethod + def get_task_bar_list(cls): + return json.loads(bpy.context.scene.BIMWorkScheduleProperties.task_bars) + + @classmethod + def add_task_bar(cls, task_id): + task_bars = cls.get_task_bar_list() + task_bars.append(task_id) + bpy.context.scene.BIMWorkScheduleProperties.task_bars = json.dumps(task_bars) + + @classmethod + def remove_task_bar(cls, task_id): + task_bars = cls.get_task_bar_list() + if task_id in task_bars: + task_bars.remove(task_id) + bpy.context.scene.BIMWorkScheduleProperties.task_bars = json.dumps(task_bars) \ No newline at end of file