Skip to content

save_scene

SaveCurrentScene

Bases: InstancePlugin

Save current scene

Source code in client/ayon_max/plugins/publish/save_scene.py
 7
 8
 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
class SaveCurrentScene(pyblish.api.InstancePlugin):
    """Save current scene"""

    label = "Save current file"
    order = pyblish.api.ExtractorOrder - 0.49
    hosts = ["max"]
    families = ["maxrender", "workfile"]

    def process(self, instance):
        host = registered_host()
        context_file = instance.context.data["currentFile"]
        current_file = host.get_current_workfile()
        if Path(context_file) != Path(current_file):
            self.log.error(
                f"Current file in context: {context_file} "
                f"does not match the actual current file: {current_file}"
            )
            raise PublishError(
                "Current file in context does not match the actual current file."
            )

        if instance.data["productBaseType"] == "maxrender":
            host.save_workfile(current_file)

        elif host.workfile_has_unsaved_changes():
            self.log.info(f"Saving current file: {current_file}")
            host.save_workfile(current_file)
        else:
            self.log.debug("No unsaved changes, skipping file save..")