Outil de sauvegarde intelligente#

import hou
import os
# basename
basename = hou.hipFile.basename()
print(basename)
if basename == "untitled.hip":
    # default vars
    directory = "E:/PROJECTS/_TUTORIALS/"
    project = "untitled"
    version = "001"
    take = "01"
    description = "blocking"
else:
    values = basename.split("_")
    directory = "E:/PROJECTS/_TUTORIALS"
    project = values[0]
    version = values[1]
    take = str(int(values[2]) + 1).zfill(2)
    description = values[3].split(".")[0]
# launching UI and override settings vars
button_choice, (directory, project, version, take, description) = hou.ui.readMultiInput(
    "Set the name and directory of your hipfile",
    ("DIRECTORY","PROJECT", "VERSION", "TAKE", "DESCRIPTION"),
    initial_contents= (directory, project, version, take, description),
    title="SAVE SCENE",
    buttons=("SAVE","VERSION UP", "CANCEL"),
    default_choice=0, close_choice=2,
)

if button_choice == 1:
    version = str(int(version) + 1).zfill(3)
    take = "01"
# define path and anme vars
path = directory + project + "/houdini/scenes"
name = project + "_" + version + "_" + take + "_" + description + ".hip"

# creating dir, if already exist: pass
if button_choice == 0 or button_choice == 1:
    try:
        os.makedirs(path)
    except FileExistsError:
        print(project + " project already exists")
# save scene
hou.hipFile.save(path + name)