Maya module paths, folders and versions

 
 
 

Creating a plug-in module allows you to create a distributable installation of a plug-in that can be saved locally or at any network location. This obviates the need to write files into the Maya installation or other hard to manage locations. Through the module file, you can easily change the distribution of your module, such as re-directing the location of many installed plug-ins to a different script folder.

Maya allows you to have multiple versions of a plug-in and load a different version depending on your OS, your Maya version, and language setting.

Module folder structure

In the module file, specify the location of the module. The location can be specified either as an absolute path or as a path relative to the location of the .mod file being read.

The module folder structure can be overwritten using the syntax <folder to override>: <new location for this folder>.

For example, to specify a new location for the scripts folder of a module, add the line:

scripts: ../commonModuleFiles/scripts

This can be a useful mechanism to share scripts/icons/presets files between modules.

ImportantYou must add a space after scripts: when specifying the path of your scripts folder; for example, scripts: c:\myScripts.

Example

Location of modules and script files:

  • C:\CustomModule\Modules\win64
  • C:\CustomModule\Modules\mac
  • C:\CustomModule\CommonFiles\scripts

Location of mod file:

  • C:\ModulesMOD\CustomModule.mod

The .mod file would contain the following lines:

+ PLATFORM:win64 CustomModule 3.10.5 ..\CustomModule\Modules\win64

scripts: ..\..\CommonFiles\scripts

A relative path was used in the first line that specified the location of the module relative to the location of the mod file (C:\ModulesMOD\CustomModule.mod). In the second line, a relative path was used to specify the location of the scripts folder relative to the module location (..\CustomModule\Modules\win64).

Subfolders of a module folder

By default, Maya ignores all subfolders included in a module. In order for Maya to consider subfolders of a module, you must request recursive behavior for that folder using the [r] keyword; for example, as follows:

[r] scripts: ..\..\CommonFiles\scripts
.folders (that is, folders starting with a ‘.’, also known as hidden folders) are ignored even if the [r] keyword is set. The folder is not parsed recursively, nor is it added to Maya as a search path.

Specifying the conditions for loading the module

You can specify the conditions under which the module will load. Choose among these conditions:

The following operating system conditions are supported:

For system locale, the following conditions are supported:

Use MAYAVERSION: to denote the Maya version.

ImportantYou must specify the conditions between the + and your module name.

Example

+ MAYAVERSION:2014 PLATFORM:win64 LOCALE:ja_JP CustomModule 3.10.5 ..\CustomModule\Modules\win64

In this example, the CustomModule plug-in would only be loaded for Maya 2014, with an operating system of WIN 64-bit, and with the system locale set to Japanese.

Environment variables

You can set custom environment variables using the following syntax:

MYVAR=MYVALUE

It is also possible to specify environment variables with values that are relative to the module location. To do so use the “:=” syntax.

Example

In the example above, if you want to set PYTHONPATH to C:\CustomModule\Modules\win64\python, you can simply set:

PYTHONPATH:=python

Append to the current value of a variable

You can append to the current value of a variable using the + and/or : operators. Examples as follows:

PATH += c:/myModule/bin adds ;c:/myModule/bin to the current value of the environment variable PATH.

PATH +:= bin adds ;’module location’/bin to the current value of the environment variable PATH.

Obtaining the module path

To query the module path, use the MEL command getModulePath as follows:

getModulePath –moduleName “MyModule”

This query returns: c:\MyModule.

Known limitations

The following folder types are not supported as legal module resource paths and any folders named with the following extensions are ignored by the module system:

Creative Commons License Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License