mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
refactor highligh_task code
This commit is contained in:
@@ -774,25 +774,27 @@ class Sequence(blenderbim.core.tool.Sequence):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def highlight_task(cls, task):
|
def go_to_task(cls, task):
|
||||||
def expand_ancestors(task):
|
def get_ancestor_ids(task):
|
||||||
|
ids = []
|
||||||
for rel in task.Nests or []:
|
for rel in task.Nests or []:
|
||||||
parent_task = rel.RelatingObject if rel.RelatingObject.is_a("IfcTask") else None
|
ids.append(rel.RelatingObject.id())
|
||||||
contracted_tasks = json.loads(bpy.context.scene.BIMWorkScheduleProperties.contracted_tasks)
|
ids.extend(get_ancestor_ids(rel.RelatingObject))
|
||||||
if parent_task and parent_task.id() in contracted_tasks:
|
return ids
|
||||||
contracted_tasks.remove(parent_task.id())
|
|
||||||
bpy.context.scene.BIMWorkScheduleProperties.contracted_tasks = json.dumps(contracted_tasks)
|
contracted_tasks = json.loads(bpy.context.scene.BIMWorkScheduleProperties.contracted_tasks)
|
||||||
expand_ancestors(parent_task)
|
for ancestor_id in get_ancestor_ids(task):
|
||||||
work_schedule = cls.get_active_work_schedule()
|
if ancestor_id in contracted_tasks:
|
||||||
cls.load_task_tree(work_schedule)
|
contracted_tasks.remove(ancestor_id)
|
||||||
cls.load_task_properties()
|
bpy.context.scene.BIMWorkScheduleProperties.contracted_tasks = json.dumps(contracted_tasks)
|
||||||
|
|
||||||
|
work_schedule = cls.get_active_work_schedule()
|
||||||
|
cls.load_task_tree(work_schedule)
|
||||||
|
cls.load_task_properties()
|
||||||
|
|
||||||
task_props = bpy.context.scene.BIMTaskTreeProperties
|
task_props = bpy.context.scene.BIMTaskTreeProperties
|
||||||
displayed_tasks = [item.ifc_definition_id for item in task_props.tasks]
|
expanded_tasks = [item.ifc_definition_id for item in task_props.tasks]
|
||||||
if not task.id() in displayed_tasks:
|
bpy.context.scene.BIMWorkScheduleProperties.active_task_index = expanded_tasks.index(task.id()) or 0
|
||||||
expand_ancestors(task)
|
|
||||||
task_index = displayed_tasks.index(task.id()) or 0
|
|
||||||
bpy.context.scene.BIMWorkScheduleProperties.active_task_index = task_index
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def guess_date_range(cls, work_schedule):
|
def guess_date_range(cls, work_schedule):
|
||||||
|
|||||||
Reference in New Issue
Block a user