code of the day cotd maya python

Code of the Day: PAIE

PAIE 1.3.2 script by Jakob Welner:

PAIE 1.3.2 (Python Attribute Import/Export) is a script for exporting animation and pose information to a file, and importing them onto the same (or similar) character.

Language: Python
Type: Maya Editor Script
Script Files: 1
Number of lines: 2293

Functionality: 8
The code is quite useful is saving out and loading poses and attributes onto similar (at least in name) objects. It does rely heavily on naming conventions, but is overall a useful tool (giving information about when a file was saved, as well as uses the python pickle module to save out its data.

Design: 8
The code base makes good use of classes and object oriented programming techniques. The code does a good job of checking for exceptions, although in a few places I think checking the input may well prevent an exception from being thrown (such as initializing the GUI class), but some programmers do prefer exceptions in some cases (I prefer not to see it on class initialization without any variables however). There are a few places where both evalDeferred are used to spawn MEL code, but in unusual ways that seem like they might have other solutions (especially when creating the UI). While the data uses the pickle module, I can’t help but feeling that using a standard format (like XML or JSON) might make the data more reusable and extendable than writing a custom format.

Style: 8
The code follows pep8 pretty closely (only ~20 warnings from running the code). However there are a few areas that would perhaps benefit from moving the code out into separate files. While the class architecture does help, the overall size of the file is bordering on being a bit larger than it needs to be, especially with standalone classes available which would promote reuse of the package/module. A few of the functions (especially reading and writing) are quite large and the code path can be a bit complex in these cases.

Documentation: 7
The header information is quite good, and there are comments through the code base, but not every class is documented, and doc strings are not consistently used, which would help improve the readability of the code. The example documentation of the structure is good and it helps that most of the code has good variable and class names.

Reusability: 8
The code has a number of pieces that could be reusable as the class architecture and OO development approach naturally does. There are a few places that the code may benefit from additional comments, and there are a couple global variables (debugger and UI) that would make debugging a bit more complicated. Using a custom file format means more care has to be done on writing any extensions, but otherwise is quite straightforward.

Overall: 8.5
Overall, nice functionality implemented in a useful and elegant way. The functionality is pretty useful, and while there are some tools that do similar things, I think the underlying architecture of this script is for the most part well thought through.

Until next time,
Michael Hubbard

Leave a Reply

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