Categories
code of the day cotd maya mel

Code of the Day: SRB-AnimTransfer

SRBAnimTransfer 0.2.0 script by Suchan Bajracharya: http://www.creativecrash.com/maya/downloads/scripts-plugins/animation/c/srb-animtransfer–2

SRBAnimTransfer 0.2.0is a tool for transferring animation from one object to another with options for mirroring the keys across different axis for translate, rotate and scale.

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

Functionality: 6
The functionality is pretty straightforward, it allows selecting a source and destination object and options for mirroring across different axis, copying custom attributes, and copying a set of keys from the timeline. Overall, the script does not offer a lot of functionality, but what is there is useful and well organized in terms of usability.

Design: 5.5
The code is quite small and only has two functions (one for UI the other for the applying). The UI function is well organized and straightforward, but the apply seems to be doing a bit too much. Separating out some of the logic (like validating parameters from the UI, and getting values from the UI into separate functions would improve the design and make the code more robust and reusable. The code uses error code values but never returns them in the function. In some cases a variable will be set and checked in the next if statement to see if it was set, rather than simply returning the error code message directly.

Style: 6
The code formatting is quite consistent although only uses indentation in the UI elements, and does not use any indentation for the code logic. This makes a few parts of the code difficult to follow in a few places, that is only offset by the fact that there is very little nested logic and most code if branching is only 2 levels deep. Still, it is surprising to see such care in the UI code and not in the actual logic. The code in places does a bit much, but overall has a good commenting style to break up parts of the function.

Documentation: 8
The code documentation is pretty good, instead of separating out the code into different functions, a lot of comments are used to break up parts of the logic. The code does a good job in describing what is going on, and the package includes a sample maya (.ma) file to show a simple example of applying an animation onto a cube. The code does follow the traditional MEL paradigm of sourcing the script and then calling the function name (from the script name), but additional documentation on how to use the script is always nice to have.

Reusability: 6
Maintenance wise the code is very small and thus would be easy to refactor, bugfix and change. As it stands, nothing can be used in isolation from the UI, so can not be easily extended or expanded upon.

Overall: 6.5
The code functionality is straightforward and to the point. It is sometimes easy to get into a feature creep with a tool, but the options that are provided are pretty useful and would likely help in certain workflows (especially where a lot of mirroring of keys has to take place).

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

Leave a Reply

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