evalDeferred syntax


#1

Hello all,

I’m trying to launch Maya from the command line batch file and run a Python script once launched. I’m looking into the evalDeferred command so I can run it once the UI etc. has been loaded. Here’s my batch command:

start “” “%ProgramFiles%\Autodesk\Maya2019\bin\maya.exe” -command evalDeferred(python(“execfile(‘Z:\myScript.py’)”))

The issue is that the script runs but in the Editor log I see an error:

// Error: line 1: Invalid argument: //

I think it’s an issue with the Mel syntax. To reproduce the error in Maya, when I run the below syntax in Mel, I get a similar error (errors on line 2):

print(“before\n”);
evalDeferred(print(“during \n”));
print(“after\n”);

Any ideas what I’m doing wrong here? Thanks for the help.


#2

I got this working, so posting if it helps anyone. It was the combination of quotes and escape characters I was getting wrong:

start “” “%ProgramFiles%\Autodesk\Maya2019\bin\maya.exe” -command “evalDeferred -lowestPriority ““python(\”“execfile(‘Z:/myScript.py’)\””)”""";"

and

print(“before\n”);
evalDeferred(“print(“during \n”)”);
print(“after\n”);