Implimenting A Documentation System in Maya




In maya 4.5, the Attribute Editor grew an additional notes section. This allowed you to write short notes relevant to a specific node within the scene. The above view shows a transform node listed in the Attribute editor. The bottom pane contains some notes which are associated with that node.

These notes are added to a node as a new attribute, "notes". It is therefore possible to access this information simply by querying a plug to the notes attribute.

Javadoc, doxygen and doc++ are familiar tools to any programmer, which are used to automatically generate html documentation from source code. We can use Maya in a similar way, by simply parsing the text contained within the notes section, and then writing out the summary as html web pages.





Doxy Maya Usage

This little plugin example provides a simple command 'doxymaya' which can be used to generate html webpages.

Simply specify any number of input files and a single output directory and it should be away.

This code is not exactly 100% foolproof, so consider it at a starting point rather than a fully working tool.





The doxymaya function supports these arguments

-f <string> This flag can be used to specify an input maya binary or ascii file.

-od <string> This flag can be used to specify an output directory for the html files.


The plugin supports these tags within the notes section



[Source Code]


Building on our previous Batch export script, we can now add in the documentation generation as well to have a truly automated graphics build.




//--------------------------------------------------------------------------------- SETTINGS

// change this to the name of you plugin you want to use.
global string $g_plugin = "C:/Program Files/Alias/Maya6.0/bin/plug-ins/objExport.mll";
global string $g_doxyplugin = "C:/GameData/doxymaya.mll";

// change this to change the input directory
global string $g_InDirectory = "C:/GameData/";

// change this to change the html output directory
global string $g_DocDirectory = "C:/GameData/html/";

// change this to the correct output extension, obj in this case
global string $g_OutExt = "obj";

global string $g_CommandString = "doxymaya -od \"";
$g_CommandString += $g_DocDirectory;
$g_CommandString +=

//--------------------------------------------------------------------------------- DIRECTORY RECURSION
// we simply now want to recurse through the directory structure
// exporting any Maya Binary files as obj files.
// to do this we can use a number of handy mel functions,

proc RecursiveDirExport(string $dir)

  // redeclare the global so we can access it
global string $g_OutExt;
global string $g_CommandString;

// get a directory listing

string $dir_list[] = `getFileList -folder $dir -fs "*.mb"`;

// loop through each maya binary file in the directory

  // first open the file
file -open -force ($dir+$dir_list[$i]);

// strip the mb from the filename and append a new extension

$filename = ($dir + `substring $dir_list[$i] 1 (size($dir_list[$i])-2)` + $g_OutExt);

// add yet anothert file to the output command
$g_CommandString += (" -f \"" + ($dir+$dir_list[$i])+"\"");

// export the file as an objfile

file -exportAll -force -type "OBJexport" $filename;

// now get a second file list and check each one.

$dir_list = `getFileList -folder $dir`;

// loop through each file returned.

  // if we have a directory, recurse into it and export files
if( `filetest -d ($dir+$dir_list[$i])` )
  RecursiveDirExport( ($dir + $dir_list[$i] + "/") );




//--------------------------------------------------------------------------------- MAIN

// load the exporter plugin
loadPlugin $g_plugin;
loadPlugin $g_doxyplugin;

// output all of the files in the directory
RecursiveDirExport( $g_InDirectory );

// generate the html files
( $g_CommandString );



What Next?

Adding Custom Mel Functions Into the API

Automating The Graphics Build

Writing A Command Line Exporter

Writing A File Translator Plugin


Rob Bateman [2004]