Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / How to use Modules?
  RSS 2.0 ATOM  

How to use Modules?
Rate this thread
 
25017
 
Permlink of this thread  
avatar
  • agrant3d
  • Posted: 03 April 2009 12:13 PM
  • Location: Montreal
  • Total Posts: 31
  • Joined: 08 December 2008 11:27 PM

Because Maya’s Modules system is largely an undocumented feature, it would be nice to put info somewhere people can find it.

Modules allows you to easily define paths for external plug-ins, scripts, presets, and icons.  They are especially useful in a production environment because they do not require users to modify their existing Maya.env files.

Here is the only documentation from Maya Help about Modules that I know of:

MAYA_MODULE_PATH
Defines the search paths for Maya module files. A module file describes the install location for certain Maya components, such as subdivision surfaces. Generally, you don’t need to set this variable. But, keep in mind that for each path extracted from the modules files, Maya appends the suffixes “plug-ins”, “presets”, “scripts”, and “icons”, and then adds the appended path to MAYA_PLUG_IN_PATH, MAYA_PRESET_PATH, MAYA_SCRIPT_PATH, and XBMLANGPATH, respectively.

The following table lists the default paths, which will always follow any path that you specify.
Default for Windows Default for Mac OS X, Linux
<user’s directory>/My Documents/maya/2009/modules
<user’s directory>/My Documents/maya/modules
C:/Program Files/Common Files/Autodesk Shared/Modules/maya/2009
C:/Program Files/Common Files/Autodesk Shared/Modules/maya
<maya_directory>/modules/

$MAYA_APP_DIR/maya/2009/modules
$MAYA_APP_DIR/maya/modules
/usr/autodesk/modules/maya/2009
/usr/autodesk/modules/maya

NoteIf you use spaces in a file path that you create, you may have problems accessing icon image files stored within that directory, because the file path does not appear in Maya. You can avoid this problem by only specifying file paths that do not include spaces.

Module files are text files that have the following syntax:

Module_Name Maya_Version_Number Module_Path

For example:

MyModule 2009-x64 C:\MyModule

There doesn’t appear to be any functions to query the path of a module.  In BonusTools they use the mel command “whatIs” on one of their scripts and then parse the string to extract the module path like so:

string $btPath = `whatIs bonusToolsMenu`;
//string $buffer[];
//subtract magic number of 24: "Mel procedure found in: "
int $numCharacters = `size($btPath)`;
$btPath = `endString $btPath ($numCharacters-24)`;
//subtract magic number of 18: "scripts/bonusToolsMenu.mel"
$numCharacters = `size($btPath)`;
$btPath = `substring $btPath 1 ($numCharacters-27)`;

Shelves, unfortunately, do not appear to be supported. :(

If anyone knows of further documentation or corrections, please post here!

Autodesk - My Modules wishlist:
add this mel command: getModulePath(string $moduleName) to return path of given module.
add shelf support.
add support for userSetup.mel in module (or something similar: moduleSetup.mel)



Replies: 0
avatar
  • agrant3d
  • Posted: 03 April 2009 06:22 PM

Whoops, I found this feature is documented in the API documentation here:

file:///C:/Program%20Files/Autodesk/Maya2009/docs/Maya2009/en_US/API/class_m_fn_plugin.html



Replies: 0
avatar

Been trying this system out but I’m having problems with the Maya_Version_Number.

No matter what I put in there, Maya uses all of the modules listed in the file. Even tested with a really old Maya version with the same result.

Example from one of my tests with different Maya versions.

Tools2011 2011  Q:\perforce\artTools\maya\2011
Tools2011Override 2011  Q:\perforce\artTools\maya\2011\override
Tools2011x64 2011-x64 Q:\perforce\artTools\maya\2011-x64
Tools2011x64Override 2011-x64 Q:\perforce\artTools\maya\2011-x64\override
Tools2010 2010  Q:\perforce\artTools\maya\2010
Tools2010Override 2010  Q:\perforce\artTools\maya\2010\override
Tools7 7.0  Q:\perforce\artTools\maya\7

Has anyone used this successfully?



Replies: 0
avatar
  • rasto
  • Posted: 19 February 2011 11:22 PM

It’s not Maya_Version_Number it is Module_Version_Number !

example:

myModule 1.3 /opt/MyCompany/myModule


CG Artist
http://www.toxik.sk

Replies: 0