|03 March 2013||#1|
Join Date: Apr 2009
Having trouble making Python communicate with MEL
What I'm trying to do is write a Python script that (among many other things), allows you to specify the location of a MEL script that it will then run. However I'm having trouble using the maya.mel.eval command.
Namely, you can't use the source command to grab a MEL script with a variable. It has to be
source "file location" ;
And if you want to use a variable you have to do it using an eval. Easy.
string $scriptpath = "file location" ;
string $melSource = ("source \""+$scriptpath+"\" ;") ;
eval $melSource ;
So this works totally fine in MEL. However, Python seems to be having trouble doing it.
When I try
maya.mel.eval('string $melSource = ("source \""+$scriptpath+"\" ;") ;')
I get back that it tried to run
// Error: string $melSource = ("source ""+$scriptpath+"" ;") ; //
Which is NOT what I wrote. You can see that the integral \ are missing, which means the MEL script won't work. Why would python be removing those before running the MEL script? Can someone help me out with a way around this?
|03 March 2013||#2|
Where's my pony?
vfx & creature td
Join Date: Jun 2003
Why are you trying to grab the return value to a mel variable if you are working in python?
For example I have a mel script called addPadding.mel that takes two arguments, the original number and the number of chacters to pad it with, and it returns a string.
(nobody would really use mel to pad a number in python - just wanted to show a simple example)
|03 March 2013||#3|
Join Date: Apr 2003
Here is another way:
Digital Characters R&D - Suntoucher Labs
|03 March 2013||#4|
Join Date: Sep 2003
Thread automatically closed
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
|Thread Closed share thread|