Bases: PreLaunchHook
Create Temp Zprj File to Marvelous Designer.
The temp zprj file would be created in Marvelous Designer prior to the launch of the software if there is no last workfile
Hook GlobalHostDataHook must be executed before this hook.
Source code in client/ayon_marvelousdesigner/hooks/pre_launch_workfile.py
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 | class CreateTempZprjFile(PreLaunchHook):
"""Create Temp Zprj File to Marvelous Designer.
The temp zprj file would be created in Marvelous Designer prior to
the launch of the software if there is no last workfile
Hook `GlobalHostDataHook` must be executed before this hook.
"""
app_groups: ClassVar = {"marvelousdesigner"}
order = 12
launch_types: ClassVar = {LaunchTypes.local}
def execute(self) -> None:
"""Execute the pre-launch hook to create temp zprj file."""
last_workfile = self.data.get("last_workfile_path")
if self.data.get("start_last_workfile") \
and last_workfile \
and os.path.exists(last_workfile):
self.log.info("It is set to start last workfile on start.")
else:
source_template_file = os.path.join(
MARVELOUS_DESIGNER_HOST_DIR, "default_zprj", "Untitled_MD.zprj"
)
staging_dir = tempdir.get_temp_dir(
self.data["project_name"],
use_local_temp=True
)
spm_filename = os.path.basename(source_template_file)
last_workfile = os.path.join(staging_dir, spm_filename)
shutil.copyfile(source_template_file, last_workfile)
self.launch_context.env["AYON_TEMP_DIR"] = staging_dir
self.launch_context.launch_args.append(last_workfile)
|
execute()
Execute the pre-launch hook to create temp zprj file.
Source code in client/ayon_marvelousdesigner/hooks/pre_launch_workfile.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 | def execute(self) -> None:
"""Execute the pre-launch hook to create temp zprj file."""
last_workfile = self.data.get("last_workfile_path")
if self.data.get("start_last_workfile") \
and last_workfile \
and os.path.exists(last_workfile):
self.log.info("It is set to start last workfile on start.")
else:
source_template_file = os.path.join(
MARVELOUS_DESIGNER_HOST_DIR, "default_zprj", "Untitled_MD.zprj"
)
staging_dir = tempdir.get_temp_dir(
self.data["project_name"],
use_local_temp=True
)
spm_filename = os.path.basename(source_template_file)
last_workfile = os.path.join(staging_dir, spm_filename)
shutil.copyfile(source_template_file, last_workfile)
self.launch_context.env["AYON_TEMP_DIR"] = staging_dir
self.launch_context.launch_args.append(last_workfile)
|