SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / python call inside mel
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 16-03-2008, 10:50 PM   #1
suzanne
Registered User
 
Join Date: Jul 2004
Location: Vancouver
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 ...
suzanne is offline   Reply With Quote
Old 17-03-2008, 10:13 PM   #2
t1ck135
Registered User
 
t1ck135's Avatar
 
Join Date: May 2004
Location: UK
Posts: 1,991
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
__________________
Examples of bTraffic - a traffic animation tool for Maya
bFlocking - a tool for Maya 8.5+ to generate flocking and swarming behaviours
Jan/Feb Challenge 2007 Entry and W.I.P
May/Jun Challenge 2006 Entry and W.I.P
Mar/Apr Challenge 2006 Entry and W.I.P
Jan/Feb Challenge 2006 Entry and W.I.P
Nov/Dec Challenge 2005 Entry and W.I.P
Sep/Oct Challenge 2005 Entry and W.I.P
Jul/Aug Challenge 2005 Entry
www.flash-fx.net
t1ck135 is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
MEL headache! happymat27 Members Lounge 5 05-12-2010 08:43 AM
MEL headache!! happymat27 Mel Scripts & Programming 1 03-12-2010 03:41 PM

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.