View Full Version : Closing maya from cmd line after export
11-10-2010, 12:08 AM
I've written a python script that iterates through a series of folders and exports all the files found within. The script launches Maya from the command line as below
maya -file "c:\tmp\sourcefile.mb" -command 'file -force -options "" -type "customExportType" -pr -ea "c:/export/exportfile.extension"' -prompt
I can't figure out how to close each Maya command line session after export.
I added quit -force to the end of the above command but that just closed Maya before it had a chance to export.
Is there a way I could get confirmation from Maya that it has exported then force the close?
p.s. I'm very inexperienced with MEL
Thanks in advance,
11-10-2010, 11:31 AM
If you dont need the UI, you can do it with mayabatch which will be closed automatically after execution is done.
Or you write a temporaray mel script with a quit; at the end and you exectute this script instead of your -command 'file ....'
11-10-2010, 01:01 PM
just add after your maya line in the cmdline
taskkill /f /im maya.exe
assuming you're on windows with a cmd batch
11-11-2010, 02:16 AM
If you don't need the functionality of the UI or the viewport you can run maya through standalone inside the python script. long as maya is in the sys.path it should be able to load maya and execute your script. This is similar to the batch mode
Otherwise you could use
example from the docs
import maya.OpenMaya as OpenMaya
def main( argv = None ):
maya.standalone.initialize( name='python' )
sys.stderr.write( "Failed in initialize standalone application" )
sys.stderr.write( "Hello world! (script output)\n" )
OpenMaya.MGlobal().executeCommand( "print \"Hello world! (command script output)\\n\"" )
if __name__ == "__main__":
11-11-2010, 03:10 AM
Many thanks for all the help.
Making good headway now.
11-11-2010, 03:10 AM
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.