Marcus is right. subprocess is the best way. me likey.
However. you’re using pymel so before you begin be sure and set an
environment variable to turn *off *initializing plugins. Chad Vernon sussed
out this crash a week or two ago on this group.

so set this variable if you’re on widows in your environment vars:
set PYMEL_SKIP_MEL_INIT = 1;

or on linux:

setenv PYMEL_SKIP_MEL_INIT 1

test it before hand to make sure it’ll work in subprocess. you don't want
to hunt down two different issues.
in a shell type:
mayapy

you should get a python prompt then test this to make sure you don't get a
traceback. then you're ready to convert your code below to a subprocess
call.

import maya.standalone
maya.standalone.initialize()import osimport pymel.core as pm
# you should see this next line if you set the environment variable
correctly.#pymel.internal.startup : INFO : Skipping MEL initialization
cube = pm.polyCube()
## your code goes here

pm.saveAs("someFile.ma")# result: Path('someFile.ma')
os._exit(0)

​

-- 
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/CABPXW4jTXuTzP3VMbqLq3yXB9RgP%2B_9W2B10%2B3Xk9wt2Uw5%3DPA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to