code of the day cotd maya mel

Code of the Day: dp SaveScenePlus

dp SaveScenePlus 1.2.2script by diegopri:

dp SaveScenePlus 1.2.2is a tool for doing an incremental save.

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

Functionality: 6
The save works on certain naming conventions, basically, the script looks for the last character value to update or append to. The script does not work if the version number is not in the last set of characters, and has a limit of two characters for the version (up to 99). If doing a save as, the code calls the builtin functionality and does not give a version number to the first iteration.

Design: 5
The script has a few odd areas, where it calls eval on builtin mel commands endString, startString and file commands which are entirely unnecessary (makes me wonder if the author was not a fan (or did not know of) using the standard “ calls to the maya api in MEL. The instructions for overriding the markingMenu’s status line file “statusLine.mel” just to add the function is something that not everyone is going to want to do. It works well to have it on the statusLine, but may work better as a shelf button or menu item rather than overriding the builtin Maya functionality.

Style: 7
The code is tiny so only contains one function (called from the statusLine button), but still seems to have a number of variables and parsing. Separating out the file parsing into a separate function would be appropriate and while I understand the limitations of MEL, it would really benefit from using some more of the gmatch options to create a regular expression to quickly parse the validation of the filename instead of splitting the file and iterating over it.

Documentation: 8
The code documentation is decent, and the overall documentation and information is quite straightforward and useful. The documentation would do well in letting the user know they are overriding a builtin Maya file by copying it into the markingMenu tab (in case there are other issues).

Reusability: 6
The code would be easy to maintain or debug based on its size alone, however, without any parameters to pass into the function, it is not really extendable, and the code is in some places a bit unusual in its use of evals (without commenting why they are used).

Overall: 6
Overall, the script will work for someone wanting something simple and easy, but for more complex naming conventions it would be better to roll your own.

Until next time,
Michael Hubbard

Leave a Reply

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