Skip to content

save_scene

SaveCurrentScene

Bases: MayaContextPlugin

Save current scene.

Source code in client/ayon_maya/plugins/publish/save_scene.py
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 SaveCurrentScene(plugin.MayaContextPlugin):
    """Save current scene."""

    label = "Save current file"
    order = pyblish.api.ExtractorOrder - 0.49
    families = ["renderlayer", "workfile"]
    targets = ["local"]

    def process(self, context):
        host = registered_host()
        context_file = 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 file has no modifications, skip forcing a file save
        if not host.workfile_has_unsaved_changes():
            self.log.debug("Skipping file save as there "
                           "are no modifications..")
            return
        project_name = context.data["projectName"]
        project_settings = context.data["project_settings"]
        # remove lockfile before saving
        if is_workfile_lock_enabled("maya", project_name, project_settings):
            remove_workfile_lock(current_file)

        self.log.info(f"Saving current file: {current_file}")
        host.save_workfile(current_file)