code of the day cotd

Code of the Day: AKS_SpiralGen

AKS_SpiralGen 4.1.0 script by Kilik:–2

AKS_SpiralGen is a tool that creates a spiral, either by creating a cylindrical spiral from the UI or optionally taking a NURBS surface and creates a coiling spiral around the surface.

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

Functionality: 6.5
The tool has a few options, but it would be really great if the spirals could be created around a few other things (like polygons or other types of curves besides NURBS). I was getting some issues with the Help file crashing if it can’t find the help file (although I suspect that this is more of a Maya issue with the “webbrowser” command then the script itself. In a few cases the script gave a few unusual results which is mentioned in the documentation that adjusting the coils and span values might resolve it.

Design: 6
The code base logically splits up some of the functionality into a few functions, and each function is fairly encapsulated in design. The code would benefit from passing parameters instead of grabbing them from the interface, and in some cases the number of variables in a given function becomes quite long. There are a number of places that have a huge number of if statements that makes the control flow a bit difficult to follow.

Style: 4.5
The coding style is mostly consistent but there are a number of places that the spacing is unusual and makes it more difficult to read. The variable names are quite ambiguous with names like “floatField1″, “floatField2″, “floatField3″, “floatField4″ and could be a bit more descriptive (in this case something like “startRadiusField“, “endRadiusField“, “heightField” and “coilsField” would be more descriptive variable names). The switch statement with cases “a” through to “k” are very difficult to understand and are passed in as parameters which makes it even more difficult to follow.

Documentation: 7
The documentation is pretty good for both the install and the use of the tool (although if the help is not at the correct path it will crash Maya as mentioned above). The in code comments could be a bit more helpful (mostly telling the reader to look at the other doc files), but there are a few places that additional comments would be helpful.

Reusability: 4.5
The code is tightly coupled to the UI, and a few of the functions (like the actual creation of the spiral) do not take any parameters, instead grabbing them from the attributes of the UI. This makes it very difficult to reuse or extend parts of the code, and would be much more powerful if it wasn’t hardcoded to a specific implementation. The variable names in a number of places are very ambiguous and would be difficult to maintain without more comments or refactoring.

Overall: 5.5
The functionality is something that addresses a very specific need (creating spiral cylinders or from NURBS surfaces). I suppose in the right project this would be a helpful tool, but a few more options would be nice (especially working with non-NURBS surfaces) and a little more information about how to prevent some of the odd results seen would make this tool more powerful.

Until next time,
Michael Hubbard

Leave a Reply

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