Bases: PreLaunchHook
Launch dialog to select from multiple starting workfile for current task
Uses profiles to check if current context should offer artist selection from multiple workfile template.
It overrides usage of generic workfile from Workfile builder configuration.
Source code in client/ayon_wrap/hooks/pre_multiple_templates.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 | class PreLaunchMultipleTemplatesHook(PreLaunchHook):
"""Launch dialog to select from multiple starting workfile for current task
Uses profiles to check if current context should offer artist selection
from multiple workfile template.
It overrides usage of generic workfile from Workfile builder configuration.
"""
app_groups = {"wrap"}
order = 10
launch_types = {LaunchTypes.local}
def execute(self):
from ayon_wrap.workfiles.widgets import WorkfilesToolWindow
context_data = self.launch_context.data
task_entity = context_data["task_entity"]
task_name = task_entity["name"]
task_type = task_entity["taskType"]
found_profile = get_multiple_templates_profile(
context_data["project_settings"], task_name, task_type, self.log
)
if not found_profile:
return
project_name = context_data["project_name"]
folder_entity = context_data["folder_entity"]
with qt_app_context():
launch_data = {
"project_name": project_name,
"folder_id": folder_entity["id"],
"task_id": task_entity["id"]
}
workfiles_tool = WorkfilesToolWindow(launch_data=launch_data)
workfiles_tool.exec_()
workfile_path = os.environ.get("WRAP_WORKFILE_PATH")
if not workfile_path or not os.path.exists(workfile_path):
raise ApplicationLaunchFailed(f"'{workfile_path} doesn't exist!")
workfile_path = os.path.normpath(workfile_path)
self.log.debug(f"Opening {workfile_path} from multiple templates")
self.data["last_workfile_path"] = os.path.normpath(workfile_path)
self.launch_context.launch_args.pop(-1)
self.launch_context.launch_args.append(workfile_path)
|