in Installation by
Our pickers are saved in project-specific directories on a server... always the same subfolder, but the parent folder changes based on the project.  For example, for Project X, the picker for Char_X is stored here: \\server_name\projects\project_x\maya\data\MGPicker\Char_X.  For Project Y, the picker for Char_Y is stored here:  \\server_name\projects\project_y\maya\data\MGPicker\Char_Y.

I'd like to specify a relative path in the "Picker Searching Directories" preferences, so that MGPicker always knows to look in "\data\MGPicker" for the correct picker.  That relative path would be relative to the maya scene file location.... so basically ON THE SERVER, inside the relevant maya project directory.  it seems like the only relative paths that MGPicker understands are relative to "C:\Users\[user_name]\Documents\maya\MG_PickerData\".

I would use an absolute path, but the picker location varies from project to project since we store our picker files inside the Maya/data/MGPicker for each project.  I guess we could store them all in a single location on the server, and I could use an absolute path to that location, but I'd rather not have to do that.

Any idea how to make this work?  Thanks.

1 Answer

0 votes
by

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.

Warning  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.

by

Another way is to save picker as a stub node in your rig by going to  Picker / Other Save Features / Export File Path As Picker Node
The key thing is that it supports the environment variable in the path. So you can define a env variable like PROJECT_MAYA to have the value "\\\\server_name\\projects\\project_x\\maya"

Categories

...