Categories
code of the day cotd maya mel

Code of the Day: XPM

XPM.mel 2.0.0 script by ewertb: http://www.creativecrash.com/maya/downloads/scripts-plugins/interface-display/c/xpm-mel

XPM.mel 2.0.0allows MEL access to the builtin .xpm Maya icons located in the MayaRes.dll

Language: MEL
Type: Maya Editor Script
Script Files: 1
Number of lines: 8236

Functionality: 4.5
The script is interesting in that it attempts to create a window with all the icons from the MayaRes.dll, unfortunately instead of querying the dll or the icons folder, it uses an if/else for each version (and does not appear to include the 20XX series of Maya). The script creates a window with all the icons from the list and the name of the icon in the display (which is useful if you want to use builtin icons in any of your interfaces).

Design: 5.5
The code does not really share any of the list entries, nor does it have a base list that is common in all versions, but instead creates a single list (often with a significant number of duplicates, for each version). While it would complicate the code a bit to have options like (add or remove certain files), it would overall help better understand what has changed over the different versions of Maya. Otherwise, the code is very simple, but well organized.

Style: 6.5
The formatting and spacing is quite well organized, but it is really quite hard to look past a 8129 line function even if it is straightforward. Separating out the lists into separate functions would make the code more readable and while that is also an element of design, would definitely improve the style of this massive function.

Documentation: 7.5
The header and in code documentation give a good amount of information to the reader explaining what the code does (in a lot of cases with multi-line explanations which are nice). The code is not overly complex, but the comments are still nice to have on what is and is not included in the lists (no textures larger than 32×32).

Reusability: 4.5
The code is very specific to these lists of images, although the code does a pretty good job of commenting what is going on, and the actual functionality that is not related to the lists of images is pretty small. The first thing that would be worthwhile is some minor refactoring to separate out getting the lists into separate functions and organizing the code that displays the images from the code that gets the correct list of images. Otherwise the code should be fairly easy to maintain, but most of the icons in later versions of Maya seem available from the install anyway.

Overall: 4.5
It is probably still useful in older versions of Maya to see what icons are used, but about half the icons no longer exist in Maya 2012. Conceptually the idea is interesting of reusing Maya’s icons, however because you do not have any control over which icons Maya keeps (or renames). From a maintenance (and often from a clarity perspective to avoid confusion if your script does something different than the icon script) it can often be better to use your own icons.

Until next time,
Michael Hubbard
https://michaelhubbard.ca

Leave a Reply

Your email address will not be published. Required fields are marked *