View Full Version : Running Pythonscripts in Maya without the GUI
08-14-2012, 09:45 PM
Title says everything I guess.
I've written a Pythonscript and halfway the script I want to call another python script (with maya commands) and run it without opening the mayagui. I need to pass some variables from the main script to the maya script too.
My script does the same thing for Nuke, but I already managed that part of the script:
os.system(pathToNukeApplication+ ' -t nukeScript.py ' + variable1 + ' ' +variable2)
Is it possible to do this for Maya in a simular way? I've been using Pymel and regular python for the mayascript, and I'm currently working on OS X 10.7
Last time I asked a question here, I got some very good advice, very quickly. So thanks in advance!
08-15-2012, 06:07 AM
But I would recommend against a stand-alone app. It's buggy, not fully compatible, and I don't see any benefits compared to running it from the gui. If I had to run it from the outside, at the most I would have used the commandPort() interface to communicate with the gui.
08-15-2012, 10:03 AM
Forgot to mention I searched for a solution myself before asking it here on the forums. I found the mayapy thing too. It works fine, but only if I run mayapy and type my code, line for line and execute it line by line, all directly in the mayapyconsole.
That's not what I try to accomplish, I want to make mayapy directly run a script from my HD and execute it. When I tried to do this the way I did it with Nuke, it launched Mayapy and immediately closed it again, without executing the script I told it to execute...
08-15-2012, 01:06 PM
I just saved these lines in d:\test.py :
import maya.cmds as cmds
maya.standalone.initialize( name='python' )
cmds.file ('D:/test.ma', force=True, open=True)
spheres = cmds.ls('*Sphere*')
It just creates a basic set with the spheres in the scene.
Then you can launch it in the windows/osx/linux shell :
It reads the script and exectues all the actions. Is it what you're looking for ?
08-15-2012, 01:56 PM
I'm not familiar with this OS X thingy, but try to find the console (cmd.exe on windows) and run a test script of hello world using mayapy, and see if they environment is configured well. Also you should try the '-E' switch: mayapy -E hello.py
08-15-2012, 01:56 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.