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.
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.
Location of modules and script files:
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).
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
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.
+ MAYAVERSION:2016 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 2016, with an operating system of WIN 64-bit, and with the system locale set to Japanese.
You can set custom environment variables using the following syntax:
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:
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:
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: