You shouldn't be renaming the file.  Just do a scriptSaveAs() to save
the script as a new version.

 

John Vanderbeck

Technical Artist

Digital Domain Media Group

 

NOTICE: This communication may contain privileged or other confidential
information. If you have received it in error, please advise the sender
by reply email and immediately delete the message and any attachments
without copying or disclosing the contents. Thank you. 

 

 

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of
Manley Gage
Sent: Monday, January 23, 2012 1:58 PM
To: [email protected]
Subject: [Nuke-python] Nuke script version up without using the "v" in
thenaming convention

 

Hello All,

 

I have a question in regards to nukes version-ing up system. Nuke
already has a "Save New Version" button however, the company that I am
working at does not want to have the mandatory "v" in their naming
convention for their pipeline. So I made a little script to version up
without using the "v" BUT, right now the script versions up but nuke
does not switch to the new/latest save of the save file, if that makes
sense.. So I am wondering what is the way to tell nuke to version up and
to switch to the new version of the file without nuke restarting?
Basically do what nuke already does just without the "v" haha :P. I just
do not know where to even start looking for the right code to make this
happen.. so any help would be awesome :).  If this isn't a possibility
then please let me know as well.

 

(I know the script is very amateur.. I just started learning python a
week and a half ago. But I'm catching on pretty fast. Feel free to give
me pointers on my python grammar :D)

 

Thanks!

Manley

 

 

 

 

######################

 

import nuke, os

 

def nukeScripVersionUp():

 

            currentNukeScriptName = nuke.root().name()

            nukeSaveFolderPath = os.path.dirname(currentNukeScriptName)

            splitUpScriptName1 = currentNukeScriptName.split('/')

            splitUpScriptName2 = splitUpScriptName1[-1]

            splitScriptNameAndExtention = splitUpScriptName2.split('.')

            currentNukeScriptName = splitScriptNameAndExtention[0]

            splitUpCurrentScriptName = currentNukeScriptName.split('_')

            currentVersionNumber = splitUpCurrentScriptName[-1]

            decimalVersionNumber =  "1" + str(currentVersionNumber)

            addingNumber = 1

            currentVersionPlusOne = int(decimalVersionNumber) +
int(addingNumber)

            listUpVersion = list(str(currentVersionPlusOne))

            

            del listUpVersion[0]

            newVersionNumber = "".join(listUpVersion)

            del splitUpScriptName1[-1]

            nukeShotName = currentNukeScriptName.split("_")

            del nukeShotName[-1]

            nukeShotName = "_".join(splitUpCurrentScriptName)

 

            newScriptNameAndPath = nukeSaveFolderPath + "/" +
nukeShotName + "_" + newVersionNumber + ".nk"

 

            if os.path.exists(currentNukeScriptFileName):

                        os.rename(currentNukeScriptFileName,
newScriptNameAndPath)

                        print nuke.message ("Nuke Script Version Up")

            else:

                        print nuke.message ("Cannot Save")

 

######################################

_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to