Here is an example of running it through a Mel command that I used for a button inside a mel script:
string $MelCommand = "python(\"import sys\"); python(\"sys.path.append('" + > $sourceLocationPath + "')\"); python(\"import > YOURMODULE\");python(\"YOURMODULE.launchMethod()\");"; Alternatively, you could run the same code as previously stated, except you should be able to use any path this way. python("import sys"); > python("sys.path.append('" + $sourceLocationPath + "')"); > python("import YOURMODULE"); > python("YOURMODULE.launchMethod()"); Using a "launchMethod()" in this way will let all of your Python code live in another file and leaving you to not write an exuberant amount of "python();" lines. On Thursday, December 12, 2013 at 1:10:25 PM UTC-6, sam.m...@gmail.com wrote: > > I'd like to run a Maya Python Script (NOT a single Python command) from > within my userSetup.mel script. The Python script is simple but does use > some Maya-specific commands. The Pythong script for testing is: > > #Python script: > import maya.cmds as cmds > Returned=cmds.fileDialog(mode=1, title="Save Layer/Pass list for Miranda:") > > The closest I've gotten to running it from MEL is something like: > > //Within the MEL Script: > python (exec("\\Server\MyFolder\SaveLPLFile.py")); > > > I've tried various cnfigurations of \\, \\\\, //, etc to accomodate the > potential errors of escape characters but nothing seems to have any effect. > The python/exec command appears to run without error (to the Maya console) > but the actual script is not running because a cmds.fileDialog() never > appears. Even when there is a typo in the filename the command appears to > run.....apparently there is some long-standing bug in python that doesn't > return an error message properly under some instances. > > Any alternatives that might be a better method of running a Python script > from within MEL? > > > -- 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 python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b6c0d816-6131-404e-8558-16cc4dc539c4%40googlegroups.com.