Hi everyone,
could somebody help me with running script with argument(path) to save new
file maya standalone will create and save it to given location and all that
from maya.
I wrote simple python script that takes path argument and when I do it
manually openning cmd and typing mayapy path\\script.py -p “c:\\”
it works and creates simple scene with sphere named test on c drive
but I can’t figure it out how to run it from maya.
this is just concept what I need standalone to do.

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAEUzAD282xN-WZq2nGN%2BUn9fZGyd6ZGNNJ%3DBNdwJEjcWz34C_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
import os
import sys
import argparse
import maya.standalone as std
#path = sys.argv[2]


print('-----batch maya script-----')
def main(path=None):
    std.initialize(name = 'python')
    import maya.cmds as mc
    #create a file with cube named "test" on c: drive
    mc.file(f=True, new= True)
    mc.polySphere(n='test')
    mc.file(rename = path+'mayaTest.ma')
    mc.file(f=True, type = 'mayaAscii', save = True)

    #if float(mc.about(v=True)) >= 2016.0 or float(mc.about(v=True)) == '2016 Extension 2 SP2':
    print('\n[DONE]:')
    std.uninitialize()

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-p', '--path')
    args = parser.parse_args()
    main(args.path)

Reply via email to