Skip to content

save_scene

SaveCurrentScene

Bases: HoudiniContextPlugin

Save current scene

Source code in client/ayon_houdini/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
34
35
36
37
38
39
40
41
42
43
class SaveCurrentScene(plugin.HoudiniContextPlugin):
    """Save current scene"""

    label = "Save current file"
    order = pyblish.api.ExtractorOrder - 0.49

    def process(self, context):

        # Filename must not have changed since collecting
        host = registered_host()
        current_file = host.get_current_workfile()
        if context.data['currentFile'] != current_file:
            raise PublishError(
                f"Collected filename '{context.data['currentFile']}' differs"
                f" from current scene name '{current_file}'.",
                description=self.get_error_description()
            )
        if host.workfile_has_unsaved_changes():
            self.log.info("Saving current file: {}".format(current_file))
            host.save_workfile(current_file)
        else:
            self.log.debug("No unsaved changes, skipping file save..")


    def get_error_description(self):
        return inspect.cleandoc(
            """### Scene File Name Changed During Publishing
            This error occurs when you validate the scene and then save it as
            a new file manually, or if you open a new file and continue
            publishing.

            Please reset the publisher and publish without changing
            the scene file midway.
            """
        )