The most flexible way to find and load a picker is to program to the MGPickerRigListerBase and MGPickerLoaderBase.
Basically, you code two python classes, deriving from MGPickerRigListerBase and MGPickerLoaderBase.
Lister is to list out all the names of characters or props, etc in your Maya scene so that MG-Picker Studio can list them out in the top-right menu in animator mode.
Loader is to find the picker file path based on the name, and MG-Picker Studio will use it to load it when the user chooses a certain character in the top-right menu in animator mode.
You can check out here, the For Programmer Section / Loader and Lister
http://mgland.com/works/MGPickerStudio/OnlineManual/v1/English/index.html
I copied the content here:
If you wanna:
- Grab any part of your scene rig, based on the selected rig's namespace, MG-Picker studio is able to auto-load a picker file, setup namespace, and ready to be used.
- Without any selection, click the top-left "..." button to visit the menu, select any entries in the "Select All Pickers" menu to load all pickers for all scene rigs, or all characters, props, etc.
- All the mapping rules between rigs and pickers are customizable.
▪How to do that?
1.Create your own python module. One would be enough.
2.Create two classes, one inherit from MGP.loader.MGPickerRigListerBase and another inherit from MGP.loader.MGPickerLoaderBase.
MGPickerRigListerBase derived class is for listing a set of rig names (Maya rig namespace) for a certain category of asset.
You can define the method name mayaScene_* and it will be picked up. For example:
def mayaScene_characters(self):
This method list all the rig names for an asset category called "characters", then in the "Load All Pickers" menu in the more button, will have a "Load All Characters" entry.
The name of the category is all decided by you, just use the prefix "mayaScene_" for the method name.
3.With lister, now we know for what rig names that we need to load the picker files for. It is time to load them !
MGPickerLoaderBase is for this. For this class, you just override pickerFileForAssetName method:
def pickerFileForAssetName(self, assetName)
For an asset name (which is a Maya namespace string), you just return a full path to a picker file.
4.Once the python module is ready, you have two ways to make it picked up by MG-Picker Studio, choose the one that fits you:
a. Put the python module in the AutoLoaders folder in the MGPicker_Program folder in the MG-Picker Studio installation directory.
b. Put the module name or module full path in the environment variable called "MGPICKER_LOADER_PY_MODULES".
To avoid hard code the environment name, use MGP.loadermanager.MGPICKER_LOADER_LISTER_MODULES_ENV_NAME instead.
If it is just a module name instead of a full path, make sure the directory that contains the module is in sys.path beforehand.
5.Check out the "loader_example.py" example python module in MGPicker_Program/AutoLoaders/Examples folder.
For multiple lister & loader modules, use ; to separate in the MGPICKER_LOADER_PY_MODULES env variable.
For multiple modules, asset names will be merged for the same category, yet it will skip the leftover loader if one loader succeeds.