PDA

View Full Version : Knowing Python or PERL would be useful for???


StefanStavrev
10-05-2006, 07:11 AM
I just read in some book that Python and PERL can be used with MEL...

I want to go deeper and deeper in MEL so i am interested why are these used?

What you can do with MEL in conjunction with these two scripting languages?

arcsecond
10-05-2006, 08:04 PM
Well, the most fun I've found is using Python to send commands to Maya, that way I can execute arbitrary MEL commands on someone elses machine. I even wrote a little Maya/Python chat program. As a TD it lets me update someone's prefs and scripts without having to go to each and every machine. But it also lets me create random objects and move things around in their scene. :-7

But basically you can write in a real programming language that affects file systems and everything and interface it with Maya. I've made various Python scripts to check for bad frames, convert textures to low res or .map or .bot files. Walk through directory trees and convert to and from UNC paths and back and forth between different versions of Maya.

The possiblities open up when you start looking at an .ma file as just a text file that you can manipulate and do mass find and replace on.

Hope this helps.

-James

futurcraft
10-06-2006, 07:54 AM
Thanks James...!
That was a reall in-depth view of how Python scripting can be used in Maya... !! Really appreciate the info u have shared with us....
Nikhil.

Aikiman
10-06-2006, 09:59 AM
What are the main differences between Python and C++? I know neither of them but also about to delve into C++ as soon as my literature arrives. I know Houdini uses Python so it would be good to know the differences and what makes each strong in their own right.

tredeger
10-09-2006, 02:19 AM
What are the main differences between Python and C++? I know neither of them but also about to delve into C++ as soon as my literature arrives. I know Houdini uses Python so it would be good to know the differences and what makes each strong in their own right.

The greatest difference and the one which makes one or t'other the appropriate language for a given purpose is that Python is an interpreted language whilst C++ is a compiled language.

A program written in Python has it's instructions executed at run time by a python interpreter whilst a C++ program has to be compiled before it can be run. <-- not an entirely accurate statement.

There are lots of different tradeoffs which come with interpretation versus compilation and neither is superior in all cases. Basically, which you should use will depend on what you are doing.

http://en.wikipedia.org/wiki/Interpreted_language

Aikiman
10-09-2006, 02:29 AM
thanks tredeger :thumbsup: I've been learning some vector maths and looking forward to my books on C++ (god help me).

hyliandanny
01-20-2007, 07:30 AM
Ishnu'dal-dieb, everyone.

Currently, I have a MEL script that uses system calls to call a perl script. This perl script looks at a media file, counts the number of frames, and then returns to MEL, at which point MEL calls another perl script to play the file and present it to animators in a friendly way.

I'm to make it pure MEL. I ask ye MEL gurus...

1. Is this possible?
2. Someone earlier in this thread (which I found by Searching for "perl") mentioned a script that counted frames: would you mind posting it? Perhaps, as mentioned earlier in this thread.... the perl code can be put right into the MEL code? Is that correct?
3. As of now, I'm only thinking that "system(...)" is my main focus.... any advice from all ye's infinite collective knowledge?

Thanks! I really appreciate your helpin' out an intern who's learning MEL. :)

sparaig
01-21-2007, 05:53 PM
Ishnu'dal-dieb, everyone.

Currently, I have a MEL script that uses system calls to call a perl script. This perl script looks at a media file, counts the number of frames, and then returns to MEL, at which point MEL calls another perl script to play the file and present it to animators in a friendly way.

I'm to make it pure MEL. I ask ye MEL gurus...

1. Is this possible?
2. Someone earlier in this thread (which I found by Searching for "perl") mentioned a script that counted frames: would you mind posting it? Perhaps, as mentioned earlier in this thread.... the perl code can be put right into the MEL code? Is that correct?
3. As of now, I'm only thinking that "system(...)" is my main focus.... any advice from all ye's infinite collective knowledge?

Thanks! I really appreciate your helpin' out an intern who's learning MEL. :)

If you can analyze the file using MEL the same way you can using PERL, than you should be able to do everything in MEL. I wonder why you want to, though. PERL has some very nice parsing routines that MEL doesn't have. For any industrial strength text-parsing you need a more powerful scripting language than MEL. Otherwise, you'll need to implement the equivalent text-parsing code in MEL, including a more robust implementation of GREP, which would be VERY slow, IMHO.

hyliandanny
01-22-2007, 08:02 AM
If you can analyze the file using MEL the same way you can using PERL, than you should be able to do everything in MEL. I wonder why you want to, though. PERL has some very nice parsing routines that MEL doesn't have. For any industrial strength text-parsing you need a more powerful scripting language than MEL. Otherwise, you'll need to implement the equivalent text-parsing code in MEL, including a more robust implementation of GREP, which would be VERY slow, IMHO.

Thanks very much for your input! I'll be sending my boss this so he can rethink whether or not he wants me to continue on this project!

The parsing situation was definitely what I was considering as well. As it is, the PERL script parses through a file which seems to be the descriptor for what the media file is, and looks for numbers separated by decimal points, etc., that sorta stuff. I wanted to know whether there was something in MEL that would be equivalent, thus making my task possible. If I have to build it all myself, though, it's going be larger than what my head honcho has in mind.

I think I'll ask him for the MEL Dynamics project back. Thanks for answering to my inquiries, everyone! You all rock!

sparaig
01-24-2007, 12:07 AM
Thanks very much for your input! I'll be sending my boss this so he can rethink whether or not he wants me to continue on this project!

The parsing situation was definitely what I was considering as well. As it is, the PERL script parses through a file which seems to be the descriptor for what the media file is, and looks for numbers separated by decimal points, etc., that sorta stuff. I wanted to know whether there was something in MEL that would be equivalent, thus making my task possible. If I have to build it all myself, though, it's going be larger than what my head honcho has in mind.

I think I'll ask him for the MEL Dynamics project back. Thanks for answering to my inquiries, everyone! You all rock!


there's only 2 or 3 text-parsing routines in MEL and they are quite limited compared to PERL's because of how MEL works. You can't extract multiple bits of text using a single function call like you can with PERL grep.

My limited understanding is that Python is now more of a "first class" language for Maya than PERL is. Python (I'm fairly certain) has all the standard GREP capabilities, so if you need a "one-language for controlling MAYA"solution, I'd go with Python. I'm not a big Python fan, but it certainly will beat MEL as far as text-parsing goes and since you should be able to use all MEL commands from within Python, it might be more what you're looking for (assuming you don't mind learning/using Python, of course).

CGTalk Moderation
01-24-2007, 12:07 AM
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.