[Closed] How to pass global variables between maxscript and python ?
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
What version of Max are you using? This is a very simple example, but if you are using 2017 pymxs will work.
import pymxs
import MaxPlus
#Create a global using MaxScript
MaxPlus.Core.EvalMAXScript('''
global msString= "Test String"
print msString
''')
#Print and modify using Python
rt = pymxs.runtime
print rt.msString
rt.msString = "Final String"
#Print using MaxScript
MaxPlus.Core.EvalMAXScript("print msString")
Thanks a Lot @martinez ,
I was trying to get file path from Maxscript, then edit it in python then export back into Maxscript environment.
But “” and “.” character really gave me hard time.
I am not really sure If I am clear but I was working on that for a WEEK! I was using MaxPlus.FPValue.Get() and MaxPlus.FPValue.Set()
This is what I’ve done, to bake texture in MAX With Python,
…
import MaxPlus
import pymxs
rt = pymxs.runtime
MaxPlus.FPValue() MaxPlus.Core.EvalMAXScript(“texture_path = getDir #MaxData +#image_dir”)
print rt.texture_path
rt.texture_path = rt.texture_path + “.png”
print rt.sako MaxPlus.Core.EvalMAXScript(“print texture_path”)
…
<3 <3 <3