Create a module and expose variables within that module. Because Maya's python 
session is continuos any on-the-fly changes to those variables will remain 
throughout the maya session…. An example….

MyConfig.py:
# Expose a variable
some_variable = True
# End of config.py

Import that config module into the python interpreter in maya and run the 
following…
import MyConfig
MyConfig.some_variable = False


Ok, now run this…
import MyConfig
Print MyConfig.some_variable

You'll notice that it prints False ( at least until you force it to reload ) 
even though we hit run two times. We do this for some of our tools here, and 
then wrap insert save and initialisation code to store the data between 
separate maya sessions.

Another option is to use Maya's optionVar dictionary and store your data in 
there, but that is less flexible with complex data types

Mike


From: Panupat Chongstitwattana <[email protected]<mailto:[email protected]>>
Reply-To: 
"[email protected]<mailto:[email protected]>"
 
<[email protected]<mailto:[email protected]>>
Date: Tuesday, 23 October 2012 06:08
To: 
"[email protected]<mailto:[email protected]>"
 
<[email protected]<mailto:[email protected]>>
Subject: [Maya-Python] global variable accessible for all modules?

Hi.

I have a couple Python UI for opening/saving scenes in our pipeline. Most of 
them share some common selection list.

client > project > episode > a few more hierarchy

I'm wondering if there's a way to store those information globally, so when I 
launch other UI they can pick up the value? I want to set the selection 
automatically to match the user's current working scene. Currently the users 
have to select everything from the ground up again.

Thanks.

--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to