add allow_autosave argument as kwargs in open_file function in nuke

This commit is contained in:
Kayla Man 2023-06-08 17:06:37 +08:00
parent 8c5b9321e4
commit 47b2a38cd4

View file

@ -19,16 +19,17 @@ def save_file(filepath):
nuke.Root().setModified(False)
def open_file(filepath):
def open_file(filepath, allow_autosave=True):
filepath = filepath.replace("\\", "/")
# To remain in the same window, we have to clear the script and read
# in the contents of the workfile.
nuke.scriptClear()
autosave = "{}.autosave".format(filepath)
autosave_prmpt = "Autosave detected.\nWould you like to load the autosave file?" # noqa
if os.path.isfile(autosave) and nuke.ask(autosave_prmpt):
filepath = autosave
if allow_autosave:
autosave = "{}.autosave".format(filepath)
autosave_prmpt = "Autosave detected.\nWould you like to load the autosave file?" # noqa
if os.path.isfile(autosave) and nuke.ask(autosave_prmpt):
filepath = autosave
nuke.scriptReadFile(filepath)
nuke.Root()["name"].setValue(filepath)