Page 1 of 1

Version-up script for Clarisse (Nuke Style)

Unread postPosted: Fri Nov 08, 2013 3:24 pm
by Arvid
I made a script to automatically save a new version of your project using the same conventions as Nuke. It's especially useful in combination with the $PNAME variable for your output paths because it makes it easy to version-up in Nuke. Hope you find it useful, and perhaps we can get this as a native function in Clarisse soon as well! :mrgreen:

Add it to the toolbar by right-clicking -> Add item

python code

#
# Python script for Clarisse
# Saves a new version of the project by increasing the version number, Nuke-style.
# Use a "v" followed by a number with any padding in the filename such as "file_v001.project" and the script will find the version and save a new file for you.
#



def padding(s, num, p="0"):
while len(s) < num: s = p + s
return s

def log(i):
ix.log_info(i)

def getProjectPath():
path = ix.application.get_factory().get_vars().get("PDIR").get_string() + "/"
project_file = ix.application.get_factory().get_vars().get("PNAME").get_string()

if project_file.find(".project") == -1: project_file += ".project"

project = path + project_file

return path, project, project_file


def numeric(s):
try:
return int(s), True
except:
return "", False

def versionUp(n = ""):
path, project, file_name = getProjectPath()

file = project

if len(n)>0: file = n # use argument passed if there is one

v = file.rfind("v")

if v == -1: return file, False # no "v" found

b = ""
for i in range(v+1,len(file)): # look for numbers following the "v"
n, ok = numeric(file[i])
if ok: b = b + file[i]
else: break # stop looking at the first non-number

pad = len(b)
if pad == 0: return file, False # the v had no numbers after it

version, success = numeric(b) # get integer from string

if not success: return file, False # non-number snuck in?
version = version + 1

restr = padding(str(version), pad) # add back padding zeroes

return file[:v] + "v" + restr + file[v+pad+1:], True # construct new project name and return





new_name, success = versionUp()

if success: ix.save_project(new_name)

Re: Version-up script for Clarisse

Unread postPosted: Tue Dec 10, 2013 11:59 am
by isoyann
Works like a charm, nice work! :)

Re: Version-up script for Clarisse (Nuke Style)

Unread postPosted: Thu May 01, 2014 12:36 am
by jhoey
Oh, that is handy. Thanks, Arvid!

Re: Version-up script for Clarisse (Nuke Style)

Unread postPosted: Fri Jun 17, 2016 5:36 pm
by vinyvince
Super cool!

Thanks for sharing with us :)



vinyvince

Posts: 27
Joined: Sun May 29, 2016 12:50 pm