Closing maya from cmd line after export

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  11 November 2010
Closing maya from cmd line after export

Hi guys,

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 November 2010
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 November 2010
just add after your maya line in the cmdline

taskkill /f /im maya.exe

assuming you're on windows with a cmd batch
maya@reddit r/maya
  11 November 2010
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.standalone
 import maya.OpenMaya as OpenMaya
 import sys
 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 November 2010
Many thanks for all the help.
Making good headway now.
  11 November 2010
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 11:34 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.