Skip to content

pre_auto_load_plugins

MayaPreAutoLoadPlugins

Bases: PreLaunchHook

Define -noAutoloadPlugins command flag.

Source code in client/ayon_maya/hooks/pre_auto_load_plugins.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class MayaPreAutoLoadPlugins(PreLaunchHook):
    """Define -noAutoloadPlugins command flag."""

    # Before AddLastWorkfileToLaunchArgs
    order = 9
    app_groups = {"maya"}
    launch_types = {LaunchTypes.local}

    def execute(self):

        # Ignore if there's no last workfile to start.
        if not self.data.get("start_last_workfile"):
            return

        maya_settings = self.data["project_settings"]["maya"]
        enabled = maya_settings["explicit_plugins_loading"]["enabled"]
        if enabled:
            # Force disable the `AddLastWorkfileToLaunchArgs`.
            self.data.pop("start_last_workfile", None)

            # Force post initialization so our dedicated plug-in load can run
            # prior to Maya opening a scene file.
            key = "AYON_OPEN_WORKFILE_POST_INITIALIZATION"
            self.launch_context.env[key] = "1"

            self.log.debug("Explicit plugins loading.")
            self.launch_context.launch_args.append("-noAutoloadPlugins")