@@ -223,32 +223,22 @@ class EnableEditingTasks(bpy.types.Operator):
223223
224224 def execute (self , context ):
225225 self .props = context .scene .BIMWorkScheduleProperties
226+ self .tprops = context .scene .BIMTaskTreeProperties
226227 self .props .active_work_schedule_id = self .work_schedule
227- while len (self .props .tasks ) > 0 :
228- self .props .tasks .remove (0 )
228+ while len (self .tprops .tasks ) > 0 :
229+ self .tprops .tasks .remove (0 )
229230
230231 self .contracted_tasks = json .loads (self .props .contracted_tasks )
231232 for related_object_id in Data .work_schedules [self .work_schedule ]["RelatedObjects" ]:
232233 self .create_new_task_li (related_object_id , 0 )
234+ bpy .ops .bim .load_task_properties ()
233235 self .props .is_editing = "TASKS"
234236 return {"FINISHED" }
235237
236238 def create_new_task_li (self , related_object_id , level_index ):
237239 task = Data .tasks [related_object_id ]
238- new = self .props .tasks .add ()
240+ new = self .tprops .tasks .add ()
239241 new .ifc_definition_id = related_object_id
240- new .name = task ["Name" ] or "Unnamed"
241- new .identification = task ["Identification" ] or "XXX"
242- if task ["TaskTime" ]:
243- task_time = Data .task_times [task ["TaskTime" ]]
244- new .start = self .canonicalise_time (task_time ["ScheduleStart" ])
245- new .finish = self .canonicalise_time (task_time ["ScheduleFinish" ])
246- # TODO: duration
247- new .duration = "-"
248- else :
249- new .start = "-"
250- new .finish = "-"
251- new .duration = "-"
252242 new .is_expanded = related_object_id not in self .contracted_tasks
253243 new .level_index = level_index
254244 if task ["RelatedObjects" ]:
@@ -258,6 +248,38 @@ def create_new_task_li(self, related_object_id, level_index):
258248 self .create_new_task_li (related_object_id , level_index + 1 )
259249 return {"FINISHED" }
260250
251+
252+ class LoadTaskProperties (bpy .types .Operator ):
253+ bl_idname = "bim.load_task_properties"
254+ bl_label = "Load Task Properties"
255+ task : bpy .props .IntProperty ()
256+
257+ def execute (self , context ):
258+ self .props = context .scene .BIMWorkScheduleProperties
259+ self .tprops = context .scene .BIMTaskTreeProperties
260+ self .props .is_task_update_enabled = False
261+ for item in self .tprops .tasks :
262+ if self .task and item .ifc_definition_id != self .task :
263+ continue
264+ task = Data .tasks [item .ifc_definition_id ]
265+ item .name = task ["Name" ] or "Unnamed"
266+ item .identification = task ["Identification" ] or "XXX"
267+ if self .props .active_task_id :
268+ item .is_predecessor = self .props .active_task_id in task ["IsPredecessorTo" ]
269+ item .is_successor = self .props .active_task_id in task ["IsSuccessorFrom" ]
270+ if task ["TaskTime" ]:
271+ task_time = Data .task_times [task ["TaskTime" ]]
272+ item .start = self .canonicalise_time (task_time ["ScheduleStart" ])
273+ item .finish = self .canonicalise_time (task_time ["ScheduleFinish" ])
274+ # TODO: duration
275+ item .duration = "-"
276+ else :
277+ item .start = "-"
278+ item .finish = "-"
279+ item .duration = "-"
280+ self .props .is_task_update_enabled = True
281+ return {"FINISHED" }
282+
261283 def canonicalise_time (self , time ):
262284 if not time :
263285 return "-"
@@ -400,6 +422,7 @@ def execute(self, context):
400422 new .enum_value = data [attribute .name ()]
401423 props .active_task_time_id = task_time_id
402424 props .active_task_id = self .task
425+ bpy .ops .bim .load_task_properties ()
403426 return {"FINISHED" }
404427
405428 def add_task_time (self ):
@@ -448,7 +471,7 @@ def execute(self, context):
448471 )
449472 Data .load (IfcStore .get_file ())
450473 bpy .ops .bim .disable_editing_task_time ()
451- bpy .ops .bim .enable_editing_tasks ( work_schedule = props .active_work_schedule_id )
474+ bpy .ops .bim .load_task_properties ( task = props .active_task_id )
452475 return {"FINISHED" }
453476
454477 def convert_strings_to_date_times (self , attributes ):
@@ -498,6 +521,7 @@ def execute(self, context):
498521 if data [attribute .name ()]:
499522 new .enum_value = data [attribute .name ()]
500523 props .active_task_id = self .task
524+ bpy .ops .bim .load_task_properties ()
501525 return {"FINISHED" }
502526
503527
@@ -535,7 +559,7 @@ def execute(self, context):
535559 )
536560 Data .load (IfcStore .get_file ())
537561 bpy .ops .bim .disable_editing_task ()
538- bpy .ops .bim .enable_editing_tasks ( work_schedule = props .active_work_schedule_id )
562+ bpy .ops .bim .load_task_properties ( task = props .active_task_id )
539563 return {"FINISHED" }
540564
541565
@@ -554,6 +578,7 @@ def execute(self, context):
554578 related_process = IfcStore .get_file ().by_id (props .active_task_id ),
555579 )
556580 Data .load (self .file )
581+ bpy .ops .bim .load_task_properties (task = self .task )
557582 return {"FINISHED" }
558583
559584
@@ -572,6 +597,7 @@ def execute(self, context):
572597 related_process = IfcStore .get_file ().by_id (self .task ),
573598 )
574599 Data .load (self .file )
600+ bpy .ops .bim .load_task_properties (task = self .task )
575601 return {"FINISHED" }
576602
577603
@@ -590,6 +616,7 @@ def execute(self, context):
590616 related_process = IfcStore .get_file ().by_id (props .active_task_id ),
591617 )
592618 Data .load (self .file )
619+ bpy .ops .bim .load_task_properties (task = self .task )
593620 return {"FINISHED" }
594621
595622
@@ -608,6 +635,7 @@ def execute(self, context):
608635 related_process = self .file .by_id (self .task ),
609636 )
610637 Data .load (self .file )
638+ bpy .ops .bim .load_task_properties (task = self .task )
611639 return {"FINISHED" }
612640
613641
0 commit comments