How to pass global variables between maxscript and python?

python
maxscript
max

#1

Forixample…

–python_in_3dsmax-----

import MaxPlus

mr = “fusion”
global mr

msEval = MaxPlus.Core.EvalMAXScript
msString =’’’
flux = “capacitor”
global flux

	print mr
	'''

msEval(msString)

print flux


I can’t that


#2

I have no idea how to do exactly what you want, as I’m completely unfamiliar with the maxscript <–> python bridge.

But the global keyword in python doesn’t really work that way.
It is basically used to allow nested scopes to access and modify values in the module’s global scope.
So global only impacts the current module that you’re in.

This page has a bunch of examples and explenations:
http://www.python-course.eu/global_vs_local_variables.php


#3

-----in_maxscript-----

temp = “flux”


-----in_python(max)–

msEval = MaxPlus.Core.EvalMAXScript
msString =’’‘temp’’’

ret = msEval(msString)
print ret.Get()


        ↑
        ↓

-----in_python(max)–

msEval = MaxPlus.Core.EvalMAXScript
msString =’’‘temp = “capacitor” ‘’’

msEval(msString)


-----in_maxscript-----

print temp