I would recommend using environment variable for this sort of stuff.
It's nice and easy and will make the info available to both python and
tcl, in any name space.
In your init.py use something like:
os.environ[ 'projectNameShortUpper' ] = 'SHOWNAME'
then whenever you need to access it in python, use something like:
os.environ[ 'projectNameShortUpper' ]
or in TCL (handy for Text nodes in slates or node labels etc):
[getenv projectNameShortUpper]
much more transparent and flexible
On 4/13/12 5:49 AM, Dan Walker wrote:
Hey all,
Is there a way to have Nuke python scripts recognize init.py variables?
------------------------------------------------------------------------------------------------------------------------------------
*SHOW_NUKE_CONFIG/init.py*
* show_resolution* = ("1920 1080 1.0 ")
* projectNameShortUpper *= project_entity["short_name"].upper()
## NSN
------------------------------------------------------------------------------------------------------------------------------------
Nuke's menu.py ( *SHOW_NUKE_CONFIG/**versions/v001/**menu.py* ) picks
up the (*SHOW_NUKE_CONFIG/init.py*)**variables but, show specific
python scripts won't?!?!?!?
------------------------------------------------------------------------------------------------------------------------------------
*SHOW_NUKE_CONFIG/versions/v001/nuke_python/myPythonScript.py*
import nuke
import os
import re
def showSettings():
show_format = nuke.addFormat[*show_resolution *+
*projectNameShortUpper*]
nuke.root()['format'].setValue(show_format)
nuke.root()['fps'].setValue(frame_rate)
nuke.root()['proxy_type'].setValue(1)
nuke.root()['proxy_format'].setValue(show_format)
nuke.root()['proxy_scale'].setValue(1)
------------------------------------------------------------------------------------------------------------------------------------
Thanks,
Dan
_______________________________________________
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