had a request for what this would look like using pymel:

import pymel.core as pm
import sys

def main( argv = None ):
        print "Hello world!"

if __name__ == "__main__":
    main()


honestly, i have no idea why that example uses MGlobal.executeCommand. by
default print goes to sys.stdout. in gui mode sys.stdout goes to the script
editor and you must use sys.__stdout__  to write to the
console/shell/terminal, but in batch mode everything goes to the shell.


also, if you're on linux or osx you can add this to the top of your file:

#!/usr/bin/env mayapy

then:

chmod 777 myfile.py

as long as mayapy is on the PATH you can now execute your script directly
like this:

./myfile.py

instead of like this:

mayapy mayfile.py

-chad


-chad







On Tue, Apr 26, 2011 at 9:58 AM, Chad Dombrova <[email protected]> wrote:

>
>
>> http://download.autodesk.com/us/maya/2011help/API/hello_world_8py-example.htmlis
>>  something that I've been referencing.
>
>
> keep in mind that this example actually differs quite a bit from maya
> -batch or maya -prompt since it does not initialize any of the mel scripts
> that maya normally does (no plugins loaded, minimal optionVars, no user
> prefs, etc).  IMHO, the best way to run a python script that simulates maya
> -batch is to import pymel.core, although there is some overhead from the
> extra initialization.  it's also nice because you can write a script that
> works both in batch mode and in gui mode with no extra code.
>
> -chad
>
>
>
>
>>
>>
>> On Mon, Apr 25, 2011 at 11:56 PM, PBL_Kiran <[email protected]>wrote:
>>
>>> I just want to know how to open maya in batch mode and perform some
>>> multiple tasks on multiple files...
>>>
>>> It should be a standalone application...
>>>
>>> Ex : open every file in batch mode and create a sphere and save it.
>>>
>>> --
>>> http://groups.google.com/group/python_inside_maya
>>>
>>
>>  --
>> http://groups.google.com/group/python_inside_maya
>>
>
>

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to