Hi, I’m having trouble casting my python variables to mel when using maya standalone. The end goal is to use maya standalone to export fbx. My main py script works fine inside of maya, but I get errors trying to convert variables - here is a small test case:
import maya.standalone as standalone
standalone.initialize(name='python')
import maya.cmds as cmds
import maya.mel as mel
#set globals
mel.eval('global string $mymel;')
mypy = 'hello'
def PrintVar():
mel.eval('$mymel = python("mypy");')
mel.eval('print $mymel')
PrintVar()
So this is the error I’m getting in standalone (the script is called melvar.py):
Error: line 1: name 'mypy' is not defined
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# NameError: name 'mypy' is not defined
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "melvar.py", line 15, in <module>
PrintVar()
File "melvar.py", line 12, in PrintVar
mel.eval('$mymel = python("mypy");')
RuntimeError: Error occurred during execution of MEL script
line 1: name 'mypy' is not defined
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# NameError: name 'mypy' is not defined
Any ideas? Or even workarounds to export fbx without using mel are welcome!
THANKS!!