![]() |
![]() |
![]() |
|
Comparing MaxScript and MEL
Written by Kevin Wafer Contact : kevinwafer@kevinwafer.com (c) Copyright Kevin Wafer 2008. First version 26th Aug 2008. Last edit 20th Sept 2008. Ask questions about this tutorial on the GameArtist.net forum. Welcome to the comparing MaxScript and MEL scripting page. Some basic knowledge of Maya and Max is assumed. The primary purpose of this page is to compare some differences between the languages. I'm often going between Max and Maya, and some of the purpose of this page is for my own, and the reader's quick reference. Often I'll be in Max, creating a script for something, and I'll say to myself `in Maya I'd do it this way', and vice versa for Maya. If you work with one or the other too long, the syntax and solutions to various tasks become very much of that application. When you go back to the other application there is a moment of puzzlement, you know how to do something, but your mind needs a kick, a quick refresh to get it going. Please feel free to email any suggestions or feedback! It will be very much welcomed.
1. EXTREME BASICS1a. What are MEL and MaxScript? Short answer Q: What are MEL and MaxScript? A: MEL is a scripting language used by Maya, MaxScript is a scripting language used by Max. Q: Why should I use MEL or MaxScript? A: Automate tasks, extend and customise Maya and MEL. Long answer Scripting languages for 3D applications extend the applications with great ease and speed. They can save huge amounts of time with a programmer or technical artist on hand who can write scripts and tools with these languages. They can also solve many problems that would traditionally require a tools programmers to write a plugin. Plugins often require a lot longer to develop, and can be a nuisance for a programmer to have to take the time out to write. A script can be written by a technically competant artist, or a technical artist (for the more complicated tasks), artists which are very close to the problem that requires solving. For tasks that require brute force and massive computation, a plugin will be faster at doing this task. But for 90% of other tasks, scripting can be used very successfully. If pushed, it's possible to create custom scene importers and exporters with only the scripting languages. 1b. What are the primary differences? Short answer Q: Which is better MaxScript or MEL? A: This is quite subjective, I would suggest that MEL is more flexible but is harder for an artist to learn. Q: How different are MaxScript and MEL? A: The syntax is quite different, the main differences lay in the handling of scene data and the application's functions Long answer MaxScript's syntax is basic from a programmer's point of view. MEL's syntax is more related to other programming languages that programmers use frequently, such as C++ and Java. I personally have a preference for MEL because it's easier to read the code. I find MaxScript can be a little too basic in presentation sometimes. Also MEL uses programming standards, such as code commenting syntax, where as Max uses a different syntax for putting comments in your code which can be quite annoying sometimes! You'll find the biggest challenges lay in the accessing of the available functions of the applications. Maya is more transparent and flexible in giving you the ability to access pre-defined functions. Max can be quite a challenge! When using in built functionality in your scripts, it can force UIs to pop up on you which are not possible to suppress. This can be frustrating, often requiring a rewrite of the built in function which has already been written for Max. Extending has the same issue, and it's often better to write something from scratch than extend what is already there due to bugs or inflexibility. I once had to re-write practically the whole XRefing system in Max for this reason. 1c. Where do I start with the scripting languages? Short answer Q: Where do I start? A: There are many tutorials around for MEL and MaxScript which I recommend reading, including my own. Q: How do I get to the script editor in MEL? A: In the Maya menu, Window -> General Editors -> Script Editor. Q: How do I get to the script editor in Max? A: In Max press F11 or go to the menu item MAXScript -> MAXScript listener Long answer Contrary to many tutorials that suggest you build primatives and transform them with script as a start point. I believe selecting objects in your scene, and using object selections is the first real world task you'll need to figure out how to do. Max and Maya handle objects in your scene differently. Selecting objects, or types of objects sometimes isn't as trivial as you'd imagine.
2. COMPARING THE BASICS2a. How do I select an object in MaxScript and MEL?Short answer Q: How do I select an object in MEL? A: select myObjectName Q: How do I select an object in MaxScript? A: select $myObjectName Q: How do I get a current object selection in MEL? A: string $objs[] = `ls -selection`; Q: How do I get a current object selection in MaxScript? A: objs = getCurrentSelection() Long answer
Selection of objects, and aquiring user selections of objects are essential in most scripts. The basic selection
of a node/object by name in Max and Maya are quite similar. Max uses the dollar symbol (`$`) as a shorthand version of selection.
For example you can enter `$` in the MaxScript command line and a list of your current selection will be returned. Ask questions about this tutorial on the GameArtist.net forum. Kevin Wafer has been an industry professional since 1994. You can contact him at kevinwafer@kevinwafer.com Back to menu |