Hi Manley,

You might also want to take a look at how Nuke is doing it in the first
place:

Take a look at nukescripts.version.py and nukescripts.script.py.

If you want to accommodate for a specific naming convention in your
facility for both scripts and renders, you might find it easier to override
the functions in nukescripts.version, rather than rolling your own function
for scripts, then renders, etc.

So, you could have your own module where you re-define the version_get,
version_set, version_up and version_down functions, and then override the
nukescripts.version module like this:

nukescripts.version = your_own_version_module

That way you can drive the behavior of the existing "versioning" tools,
without having to create a new function for each case.

Hope that helps.

Ivan


On Mon, Jan 23, 2012 at 12:45 PM, Manley Gage <[email protected]>wrote:

> Awesome! Heh heh I over thought that a little. Thank you Mr. Vanderbeck :)
>
>
>
>
>
> 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: nuke-python-bounces at support.thefoundry.co.uk 
> <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python>
> [mailto:nuke-python-bounces at support.thefoundry.co.uk 
> <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python>] On 
> Behalf Of
> Manley Gage
> Sent: Monday, January 23, 2012 1:58 PM
> To: nuke-python at support.thefoundry.co.uk 
> <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python>
> 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
>
>
_______________________________________________
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