Skip to content

save_scene

SaveCurrentScene

Bases: ContextPlugin

Save current scene

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

    label = "Save current file"
    order = pyblish.api.ExtractorOrder - 0.49
    hosts = ["silhouette"]

    def process(self, context):
        host = registered_host()

        # 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 unsaved changes..")
            return

        # Filename must not have changed since collecting
        current_file = host.get_current_workfile()
        if context.data["currentFile"] != current_file:
            raise KnownPublishError(
                "Collected filename mismatches from current scene name."
            )

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