View Full Version : transforming MEL to equivalent maya Plugin?
viper_07 08-17-2003, 08:11 AM I'm new in maya API
but i wrote some MEL.
Since some of my MEL is very slow(some action takes few minites to complete). I read that PLugin can have 20 time faster speed. and covers all what MEL can do.
I just wonder if there are any method to make an MEL to become an equvalant function plugin
do i need to rewrite all the thing or MEL can be included in the API writing and thus compiled, or any "wrapper" , converting method.?
thanks for any advice
|
|
rokandic
08-17-2003, 12:11 PM
This isn't always as easy as it looks since you must convert all MEL commands in your script to equivalent API code. You must realize that all commands you call in MEL are already written API code. So things can sometimes be 20 times faster but not always. It will be 20 times faster if that command is calculating a lot of things that you actually don't need.
So my advice is don't turn all the code into MEL, just check where your script is getting slowed down and replace that code with new API commands that calculate only what you need. Then you might get some speed up.
This very much applies to node networks. You might have a lot of nodes in single network to calculate simple things. You could write one node without thousands of attributes that you don't need to replace all those nodes. This usually gives good speed up results.
dmcgrath
08-17-2003, 11:42 PM
Also a thing that can speed up your workflow is to use procedures in Maya that are already installed. Maya reads a bunch of stuff in your script editor as it is opening, if there are globalProcs, or things like that, that you have written, maybe your way is less effecient then what may already be installed.
viper_07
08-18-2003, 04:34 AM
I'm not a programmer, I wrote some hundred lines MEL but I know very little in C++ porgramiing. any advice on where i should start to do what I want to do?
dmcgrath
08-18-2003, 07:24 AM
You probably need to do something I want to do, that is take a C++ class.
And also get David Gould's book:
http://www.davidgould.com/Books/index.html (http://www.davidgould.com/Books/index.html)
Dig in!
mark_wilkins
08-18-2003, 08:19 PM
David's book is a great place to start for API development. One thing to realize though is that when you're writing plug-ins, there are many things that you will have to have your plug-in call a MEL command to do! There's not always an API-optimized way to do everything.
-- Mark
mhovland
08-18-2003, 09:34 PM
Also just making calls to MEL from within a plugin isn't going to give you any speed increase. Calling MEL from within a plugin is the same as calling MEL commands from MEL. In fact, it might even be a bit slower.
You will need to re-write the entire thing in the API to see any increase.
Now, if you don't have any C++ programimng experience, I would recommend either taking some C++ courses, or finding a good book on C++ and starting there. I had to re-write a math intensive MEL script in the API, and it was far from easy. I had a programmer here to ask questions and help out when I hit a wall (which was often).
If you understand and are really comfortable with MEL, you will understand alot of the basic programming concepts that are the same between MEL and the API. I had the hardest time understanding (I still don't understand it) how the API works and the bigger concepts of C++ (inheritence and all that goes with object oriented programming).
Good luck,
mark_wilkins
08-18-2003, 09:40 PM
My point was that the API doesn't necessarily give you a C++ method that corresponds to any particular MEL command. For example, MFileIO does not support all the functionality of the MEL file command. Because of this, you will probably be stuck putting calls to MEL commands in your plug-ins, which as Mike says, may even be slower than the same thing in a MEL script.
-- Mark
dmcgrath
08-19-2003, 12:44 AM
I hadn't even thought about the fact that calling MEL commands from within an API might even be slower than just running them form MEL. Thanks for the tip.
I am a huge fan of making things faster (more so for the creation process, than for processor speed). So I always like to call on other things from other scripts if possible, instead of writing redundant code. But I can begin to see that even writing a new plug-in isn't necessarily the way to go.
Thanks mhovland and Mark!
-dan
mark_wilkins
08-19-2003, 12:49 AM
The easiest way to make things faster in Maya is to use a MEL script to connect a bunch of dependency graph nodes together to do the work on the fly.
Alternatively, making a custom node can be a great speed advantage depending on what you're doing.
Making a custom command with a plug-in, however, isn't necessarily an advantage over doing the same thing in a MEL script. Usually I'd reserve this one for cases where there's really no other way (or no other way that's as nice for the user.)
-- Mark
CGTalk Moderation
01-15-2006, 09:00 PM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.