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.
Note: All module files, regardless of extension, are read by Maya.
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.
Important: You must add a space after scripts: when specifying the path of your scripts folder; for example, scripts: c:\myScripts.
Location of modules and script files:
Location of mod file:
The .mod file would contain the following module description line and script override:
+ 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).
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.
You can specify the conditions under which the module will load. The conditions need to be added to the module description line.
Three conditions can be specified: MAYAVERSION, PLATFORM, and LOCALE:
Condition | Description | Supported Values |
---|---|---|
MAYAVERSION | Specifies a base version of Maya. If this condition is omitted, the line applies to all versions of Maya. | Can be any base version of Maya, for example 2020 or 2019. |
PLATFORM | Specifies an architecture. If this condition is omitted, the line applies to all system architectures. | Can be win64, mac, or linux |
LOCALE | Specifies the system locale. If this condition is omitted, the line applies to any locale. | Can be en_US, for US English, ja_JP, for Japanese, or zh_CN, for Simplified Chinese |
+ MAYAVERSION:2019 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 2019 on Windows with the system locale set to Japanese.
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.
In the example above, if you want to set PYTHONPATH to C:\CustomModule\Modules\win64\python, you can simply set:
PYTHONPATH:=python
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.
To query the module path, use the MEL command getModulePath as follows:
getModulePath –moduleName “MyModule”
This query returns: c:\MyModule.
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: