code of the day cotd maya mel

Code of the Day: Animation and Pose Copy

Animation and Pose Copy, Batch Transfer 2.6.5 script by sin3d:

Animation and Pose Copy, Batch Transfer 2.6.5is a tool for saving and loading animation to a text file and applying the saved animation information to custom attributes from one object to another.

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

Functionality: 6.5
The functionality is decent, although requires that the joints be keyed before copying. This is fine for a number of workflows, but allowing options to copy keys from selections would be a nice option to have. The UI is pretty good, and does a decent job of mentioning most errors, but still will write out an empty file if no attributes are keyed (it would probably be better to mention that nothing is being written to the user).

Design: 6.5
The code separates out a lot of functionality into appropriate functions, but there are a few places (especially related to the UI) where the code is tightly coupled to the interface. Most of the functions are fairly small, but there are a couple (reading and writing the files) which are quite long, and may benefit from separating some of the logic into standalone functions. The placement of the functions is a little disjointed, and could group similar functions together to improve reader flow.

Style: 5
The code formatting is inconsistent, and bracket scoping, indentation and spacing are not very consistent. The style seems to change quite drastically in places, and uses different prefix naming conventions such as “ac_findNodesWithKeysProc” and “ps_findNodesWithKeysProc” which makes me think there were parts that were used from two different authors (or scripts) and then modified to fit certain needs. This type of function naming is confusing and suggests besides making the code more difficult to read, also duplicates some functionality.

Documentation: 6
The code documentation is ok, the header file does a good job describing at a high level what the functionality does, but the code does not tell you how to run it, and does not follow the traditional MEL structure of including a function with the same name as the script. To run the script in this case run the following in the MEL script editor tab.

source “Anm_AnmCopy“;


Reusability: 6
The code does have a few places where code will be reusable and maintainable, and would work as standalone functions. A lot of the code (even writing or loading from a file) is tied to the interface (both in getting variable names and refreshing the function, which could be made separate by separating out the UI and file IO with a wrapper function.

Overall: 6
The code functionality for the poses is quite good and the files saved as text files is a good approach, and gives the user quite a few options to set the directory path. A few more options (should as non-keyed values) would help the functionality, some extra error information would also be helpful, especially in debugging the transfer animation options.

Until next time,
Michael Hubbard

Leave a Reply

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