Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   python call inside mel (https://simplymaya.com/forum/showthread.php?t=29313)

suzanne 16-03-2008 10:50 PM

python call inside mel
 
How can I pass a Mel string variable into a python call from within a mel script ?

so I want to do something like this ... but this doesn't work:

string $myString;
string $myList = python("myString.split(':')");


Studio where I work cannot move totally to Maya python, but I would like to take advantage of python's string, list, and re methods from within a mel script. I'm wondering if anyone out there has done something similar. I thing I need to precede with another python call to create the python string object named myString .... but still can't get anything to work ...

t1ck135 17-03-2008 10:13 PM

Hi suzanne,

I've played about with this in the past and the following should help you on your way. The thing to remember is to make sure the python() call uses double quotes immediately inside it and then to escape any python special characters or quotes.

e.g,
Code:

python("myVar = \"hello\"");
python("print myVar")

will result in the script editor printing hello
Simon


All times are GMT. The time now is 11:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018