Isotropix Forums

Version-up script for Clarisse (Nuke Style)

Clarisse Scripting related topics

Version-up script for Clarisse (Nuke Style)

Unread postby Arvid » Fri Nov 08, 2013 4:24 pm

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)
Arvid
 
Posts: 191
Joined: Thu Jan 31, 2013 4:44 pm

Re: Version-up script for Clarisse

Unread postby isoyann » Tue Dec 10, 2013 12:59 pm

Works like a charm, nice work! :)
User avatar
isoyann
 
Posts: 602
Joined: Mon Jan 28, 2013 12:11 pm

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

Unread postby jhoey » Thu May 01, 2014 1:36 am

Oh, that is handy. Thanks, Arvid!
Jeremy Hoey
Senior Digital Matte Artist, Method Studios Vancouver
jhoey
 
Posts: 93
Joined: Sat Mar 22, 2014 10:37 am
Location: Vancouver, BC

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

Unread postby vinyvince » Fri Jun 17, 2016 6:36 pm

Super cool!

Thanks for sharing with us :)



vinyvince

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


Return to Scripting