OK, so based on a suggestion from Nathan and an old post from Javier Garcia,
here's what I have...
---------------------------------------------------------------------------------
import nuke
import os
prefs = nuke.toNode( 'preferences' )
preferences_code = """Preferences {
inputs 0
name Preferences %s
} """ % prefs.writeKnobs( nuke.WRITE_USER_KNOB_DEFS |
nuke.WRITE_NON_DEFAULT_ONLY | nuke.TO_SCRIPT | nuke.TO_VALUE )
prefs_file_ver = str(nuke.NUKE_VERSION_MAJOR) + "." +
str(nuke.NUKE_VERSION_MINOR)
preference_file = os.path.expandvars( '$HOME/.nuke/preferences' +
prefs_file_ver + '.nk' )
f = open( preference_file , 'w' )
f.write( preferences_code )
f.close()
---------------------------------------------------------------------------------
I tweaked what Javier had posted, ever so slightly, and added the current
major/minor version number of Nuke as a variable for the preferences filename.
It seems to work well...
Thanks - Javier and Nathan!
Rich
Rich Bobo
Senior VFX Compositor
Email: richb...@mac.com
Mobile: 248.840.2665
Web: http://richbobo.com
On Sep 24, 2014, at 01:03 PM, Richard Bobo <richb...@mac.com> wrote:
On Sep 24, 2014, at 12:43 PM, Nathan Rusch <nathan_ru...@hotmail.com> wrote:
Remember, Nuke nodes are written with sparse knob values, so unless you change
the value of the knob and save the preferences, it's not going to show up in
the preferences file.
Nathan - Ahh, I see that now... The localCachePath value is showing up after a
fresh save.
As far as saving them yourself goes, you might be in a situation where you need
to edit the preferences file programmatically, or re-serialize and dump the
preferences node (using node.writeKnobs(nuke.TO_SCRIPT |
nuke.WRITE_NON_DEFAULT_ONLY)) and write the result to the file yourself.
OK, thanks. I did find a nuke-python message from Javier Garcia, dated Nov. 20,
2011, that has an example of doing as you suggest. So, I’ll investigate that
route…
Thanks!
Rich
-Nathan
From: Richard Bobo
Sent: Wednesday, September 24, 2014 9:11 AM
To: Nuke Python discussion
Subject: [Nuke-python] Script - saving Nuke Prefs...
Hi,
I am making a script that makes localizing files a bit easier - using Frank
Rueter’s new LocaliseThreaded script. (Thanks, Frank!) However, due to some
very long Read node localise pathnames that Windows does not like, I need to
change the localCachePath value (the value of the Prefs - “Local File Cache -
localize to” knob) to a very short path. I am changing the value via a script,
which changes it while Nuke is open, but of course the change is only
temporary, since the Save Prefs button is not pressed. How can I save the new
localCachePath value - in effect, pressing the Save Prefs? I checked the
preferences file and the localized file path is not stored there. Where the
heck does it get saved…? Any help would be appreciated!
Thanks,
Rich
Rich Bobo
Senior VFX Compositor
Armstrong White
Email: rich.b...@armstrong-white.com
http://armstrong-white.com/
Email: richb...@mac.com
Mobile: (248) 840-2665
Web: http://richbobo.com/
"A professional is someone who can do his best work when he doesn't feel like
it."
- Alistair Cooke
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python