I manage to do this... it is a bit complex to explain, so i'll try my best. 1. Create a command calling mayapy.exe -m <script to run> <arguments> 2. Create the script you are calling with mayapy.exe, in this script you can grab the arguments sent to the script using sys.argv example: import sys # store the arguments in variables argument1 = sys.argv[1] argument2 = sys.argv[2] etc.
3. call the mayapy.exe command using subprocess. Here is part of my script... Note that I am capturing the stdout and stderr of mayaPy so I can diagnose problem more easily... you don't have to capture them. import subprocess cmdAndArgs = 'mayapy.exe -m mayaPy.avol.batchExportInit '+objExportedScene+' '+avolObj.NodeName+' '+camExportedScene+' '+str(createPreviewRender) tempFolder = os.path.dirname(objExportedScene) # Create log file sdtoutFile = r'%s\stdout.txt' %tempFolder stderrFile = r'%s\sterr.txt' %tempFolder outptr = file(sdtoutFile, 'w') errptr = file(stderrFile, 'w') # Call the subprocess using convenience method startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags = subprocess.STARTF_USESHOWWINDOW retval = subprocess.call(cmdAndArgs, startupinfo=startupinfo, bufsize=0, executable=None, stdin=None, stdout=outptr, stderr=errptr) # Close log handles errptr.close() outptr.close() This works fine for me... From maya I am exporting an object, I start a maya in background using mayapy.exe, I cleanup the object, save it, etc. In my case maya is loked because I am waiting for the stdout of the subprocess, but if you send the process and don't wait for it, maya should be free. Hope this helps On Sat, May 9, 2009 at 9:53 PM, sRheinfrank <[email protected]>wrote: > > Hi---I want to be able to capture arguments from a UI in a Maya > session and send them to Mayapy to run in the background to keep from > locking up the current session while waiting for the process to > finish--- > > Ideally, I could access mayapy through the Script Editor (through a > system call) and also pass it arguments and the right module to > process them and still be able to work in Maya while it's running in > the background... I figure using the maya.standalone module would be a > vital part of this, what I'm unclear on is just how to get it going > purely by running a command from within Maya.... > > Thanks!! > -Steve > > > > -- They say, "Evil prevails when good men fail to act." What they ought to say is, "Evil prevails." Nicolas Cage as Yuri Orlov in Lord of War. --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---
