Oct-11-2020, 10:21 PM
Hello, everybody,
I'm new in python and i'm trying to pass arguments between different scripts but they only update one way:
i'm calling the first script in maya with a shelf in maya like this:
import sys
import maya.cmds as cmds
from functools import partial
and the script called by it is called 'UiMayaTestFunction.py' and just return a variable called Var:
but if i change the variable Var = 'Hello world' in UiMayaTestFunction by for example Var = 'Gnnn', it doesn't update it,
i've got always the same print or 'Var'... 'Hello world'
Thanks by advance for any help...
I'm new in python and i'm trying to pass arguments between different scripts but they only update one way:
i'm calling the first script in maya with a shelf in maya like this:
try:
myPM.close()
except:pass
import sys
sys.path.append("C:/Users/manue/Desktop/test")
import UiMayaTest as SBIRP
reload(SBIRP)
myPM = SBIRP.createUI()this called script 'UiMayaTest.py' is a simple window with an intField entry and a button:import sys
import maya.cmds as cmds
from functools import partial
def buttonPressed(episode, *args):
passValue(episode, *args)
print '============== buttonPressed ================'
print 'EpisodeName ', EpisodeName
Var = ''
import UiMayaTestFunction
Var = UiMayaTestFunction.FindVarFunc(EpisodeName,Var)
print 'Var : ',Var
def createUI():
myWindow = "SomeWindow"
if cmds.window(myWindow,ex=True):
cmds.deleteUI(myWindow)
cmds.window(myWindow)
cmds.columnLayout( adjustableColumn=True )
cmds.text( label='Episode: ', align='left' )
episode = cmds.intField( "Episode", minValue = 100, maxValue = 1000, value =100)
cmds.button(l="Open Last LIT scene", w=150, h=30, command=partial(buttonPressed,episode))
cmds.setParent("..")
cmds.showWindow()
def passValue(episode, *args):
global EpisodeName
EpisodeName = `cmds.intField( episode, query = True, value = True)`and the script called by it is called 'UiMayaTestFunction.py' and just return a variable called Var:
def FindVarFunc(EpisodeName, Var):
print '============== FindVarFunc ================'
print 'EpisodeName:' , EpisodeName
Var = 'Hello world'
print 'Var: ',Var
return Varthe variable 'EpisodeName' from UiMayaTest to UiMayaTestFunction is well updated each time i press the button, but if i change the variable Var = 'Hello world' in UiMayaTestFunction by for example Var = 'Gnnn', it doesn't update it,
i've got always the same print or 'Var'... 'Hello world'
Thanks by advance for any help...
