Hello,

I have had to do this in a MEL script a couple of times, mainly when 
running Maya in batch mode.

In your Python script make sure you have a run function that calls all the 
functions you need for the script.

In your MEL script (make sure the script is available to be imported) and 
call in your MEL script:

python("import myscript");

python("myscript.run()");



I have never looked into "execfile" as Justin suggested but this solution 
but this solution has worked for me in the past.

I hope it helps. 

-- Ben


On Thursday, December 12th, 2013 at. 20:10:25 UTC + 1 wrote sam.ma ... @ 
gmail.com:
>
> 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 Mayan-Specific Commands. The Pythong script for testing is:
>
> #Python Script: 
> import maya.cmds as CMDS 
> Returned = cmds.fileDialog (mode = 1, title = "Save Layer / Pass drop 
> 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 
> Appear. Even when there is a typo in the filename The command Appears to 
> run ..... apparently there is some long-standing bug in python That does 
> not return an error message properly in some instances.
>
> Any alternatives That might be a better method of running a Python script 
> from within the 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/a0af08e8-5b07-4365-8268-7caa1a169b4a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to