Skip to content

save_scene

SaveCurrentScene

Bases: MayaContextPlugin

Save current scene.

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

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

    def process(self, context):
        import maya.cmds as cmds

        current = cmds.file(query=True, sceneName=True)
        assert context.data['currentFile'] == current

        # If file has no modifications, skip forcing a file save
        if not cmds.file(query=True, modified=True):
            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)
        self.log.info("Saving current file: {}".format(current))
        cmds.file(save=True, force=True)