Skip to content

zbrush_startup_script

Pre-launch to force zbrush startup script.

ZBrushStartupScript

Bases: PreLaunchHook

Inject AYON environment to Zbrush.

Note that this works in combination whit Zbrush startup script that is creating the environment variable for the AYON Plugin

Hook GlobalHostDataHook must be executed before this hook.

Source code in client/ayon_zbrush/hooks/zbrush_startup_script.py
 9
10
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
class ZBrushStartupScript(PreLaunchHook):
    """Inject AYON environment to Zbrush.

    Note that this works in combination whit Zbrush startup script that
    is creating the environment variable for the AYON Plugin

    Hook `GlobalHostDataHook` must be executed before this hook.
    """
    app_groups = {"zbrush"}
    order = 11
    launch_types = {LaunchTypes.local}

    def execute(self):
        executable_path = self.launch_context.launch_args.pop(0)
        self.launch_context.env["ZBRUSH_EXE"] = executable_path
        # Pop rest of launch arguments - There should not be other arguments!
        remainders = []
        while self.launch_context.launch_args:
            remainders.append(self.launch_context.launch_args.pop(0))

        new_launch_args = get_ayon_launcher_args(
            "run", get_launch_script_path(), executable_path
        )

        # Append as whole list as these arguments should not be separated
        self.launch_context.launch_args.append(new_launch_args)
        startup_args = [
            os.path.join(ZBRUSH_HOST_DIR, "startup", "startup.txt"),
        ]
        self.launch_context.launch_args.append(startup_args)

        if remainders:
            self.log.warning((
                "There are unexpected launch arguments in Zbrush launch. {}"
            ).format(str(remainders)))
            self.launch_context.launch_args.extend(remainders)