After going through every possible resources I came to conclusion that I need an urgent help to pass global variables from a function to others inside a Module in Python.
Actually I am writing a small UI in Autodesk Maya2010, here is a brief about the problem.
In the following code I have got two Module Level Global Variables, I am assigning values to them inside a function. Now if I pass these variables directly(i.e. without converting the function call and assigning it as a string) then the code works fine, however since the Command Flag of the Button Function only allows a string or a function name hence I am stuck with this way of calling the function.
The result which I get is :
temp_var=None
a_Window=None
which I have got no idea about.
Can anyone point down what exactly is happening when I use the string value as function call?
**The sample code**:
import maya.cmds;
temp_var=None;
a_Window=None;
def im_PrimaryFunc():
imSecondary_func();
def imSecondary_func():
global a_Window;
global temp_var;
a_Window=maya.cmds.window(title="Something");
a_layout=maya.cmds.columnLayout(adj=1,rs=10);
temp_var=maya.cmds.createNode("polySphere");
func_call="a_calledFunc(a_Window,temp_var)";
maya.cmds.button(label="call_aFunc",align="center",command=func_call);
maya.cmds.showWindow(a_Window);
def a_calledFunc(arg00,arg01):
print(arg00);
print(arg01);
Try this code
Remember that you are writing python code so there is no need to add ; in your code 🙂