Bases: PreLaunchHook
Create Temp Spm File to SpeedTree.
The temp spm file would be created in SpeedTree prior to the launch of the software if there is no workfile to launch.
Hook GlobalHostDataHook must be executed before this hook.
Source code in client/ayon_speedtree/hooks/create_temp_spm_file.py
11
12
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
60
61
62
63 | class CreateTempSpmFile(PreLaunchHook):
"""Create Temp Spm File to SpeedTree.
The temp spm file would be created in SpeedTree prior to
the launch of the software if there is no workfile to launch.
Hook `GlobalHostDataHook` must be executed before this hook.
"""
app_groups = {"speedtree"}
order = 12
launch_types = {LaunchTypes.local}
def execute(self):
workfile_path = self.get_workfile_path()
self.launch_context.launch_args.append(workfile_path)
self.launch_context.env["CURRENT_SPM"] = workfile_path
def get_workfile_path(self):
workfile_path = self.data.get("workfile_path")
if workfile_path:
return workfile_path
if self.data.get("start_last_workfile"):
self.log.info("It is set to start last workfile on start.")
workfile_path = self.data.get("last_workfile_path")
if workfile_path and os.path.exists(workfile_path):
return workfile_path
source_template_file = self.get_custom_template_path()
staging_dir = tempdir.get_temp_dir(
self.data["project_name"],
use_local_temp=True
)
spm_filename = os.path.basename(source_template_file)
workfile_path = os.path.join(staging_dir, spm_filename)
shutil.copyfile(source_template_file, workfile_path)
return workfile_path
def get_custom_template_path(self):
speedtree_settings = self.data["project_settings"]["speedtree"]
template_path = speedtree_settings["template_path"]
if template_path and os.path.exists(template_path):
return template_path
executable_path = self.launch_context.env["SPTREE_EXE"]
template_directory = os.path.dirname(
os.path.dirname(executable_path)
)
template_path = os.path.join(
template_directory, "tree_templates/Games/Blank.spm")
return template_path
|