Home  Previous Next

command (MEL/Python)

MGPickerView

Go to: MEL synopsis. Python synopsis. Return value. Flags. MEL examples. Python examples.

MEL Synopsis

MGPickerView [-activate] [-addPanel] [-activePanelIndex] [-author] [-close] [-email] [-exportPathToNode] [-exist] [-fileVersion] [-getIdFromName] [-listLinks] [-list] [-mirrorSelection] [-message] [-namespaceChangedCommand] [-namespace] [-pickerDirPath] [-pickerEnterCommand] [-pickerFilePath] [-pickerLoadCommand] [-removeAll] [-remove] [-saveAs] [-saveAsSceneNode] [-saveAsTemplate] [-setClean] [-select] [-selectPickerButtons] [-selectMode] [-selectPanelButtons] [-selectPanelIndexButtons] [-syncPickerValue] [-saveToFolder] [-saveWithinSceneFolder] [-tabLabel][-updateSceneBoundary] [-website] viewIDString

Python Synopsis

MGPickerView (viewIDString, [activate=boolean], [addPanel=string, string],[activePanelIndex=int], [author=string], [close=boolean], [email=string], [exportPathToNode=[string, string]], [exist=boolean],[fileVersion=boolean],[getIdFromName=string], [listLinks=string], [list=string],[mirrorSelection=int], [message=string], [namespaceChangedCommand=[string, string]], [namespace=string], [pickerDirPath=boolean],[pickerEnterCommand=string, string], [pickerFilePath=boolean], [pickerLoadCommand=[string, string]], [removeAll=boolean], [remove=string], [saveAs=string], [saveAsSceneNode=[string, boolean], [saveAsTemplate=string], [setClean=string], [select=string], [selectPickerButtons=int],[selectMode=int], [selectPanelButtons=int], [selectPanelIndexButtons=[int, int]], [syncPickerValue=boolean], [saveToFolder=string], [saveWithinSceneFolder=boolean], [tabLabel=string], [updateSceneBoundary=boolean],  [website=string])

MGPickerView is NOT undoable, queryable, and editable.

This command queries / edit the picker document level attributes and states.

You need to specify a picker view id string in order to query / edit it, if you does not specify any id then current active picker view will be queried / edited.
To retrieve a picker view id, use one of following commands:
   MGPicker -q -currentPickerView;     // Get current script execution view id, eg. picker load command, picker mouse enter command. Only be set during the script being executed.
   MGPicker -q -activePickerView;     // Get current active view id.

   MGPicker -q -findPickerView  "pickerNodeOrFileName"  1 "namespace";             // Find picker view id via picker node name or picker file name and namespace.

   MGPicker -q -listAllPickerViews;          // List ids of all opened picker views.

   MGPicker -e -createTempPicker;     // Create a temporary picker view and return its id.

   MGPicker -e -createPicker "pickerName" "namespace" "filePath" "nodeName";        // Create a picker view and return its id.

   MGPicker -e -readPickerNode "nodeName";       // Read in-scene picker node and return its id.

   MGPicker -e -readScenePicker "nodeName" "pickerName" "namespace" "pickerDataString";       // Read in-scene picker node and return its id.

   MGPicker -e -readPickerFile "pickerFilePath" 1;         // Read a picker file and return its id.

Return value

Depend on the flag, the return value could be string, boolean, etc.

Flags

activate, addPanel, activePanelIndex, author, close, email, exportPathToNode, exist, fileVersion, getIdFromName, listLinks, list, mirrorSelection, message, namespaceChangedCommand, namespace, pickerDirPath, pickerEnterCommand, pickerFilePath, pickerLoadCommand, removeAll, remove, saveAs, saveAsSceneNode,saveAsTemplate, setClean, select, selectPickerButtons, selectMode, selectPanelButtons, selectPanelIndexButtons, syncPickerValue, saveToFolder, saveWithinSceneFolder, tabLabel, updateSceneBoundary, website

 

Long name (short name)

Argument types

Properties

-activate(-act)

 

queryedit


In query mode, this returns if a picker view id is activated.

In Edit mode, this active a picker view by its id.

-addPanel(-ap)

string string

edit


Edit only flag, specify the panel label, and the panel layout: "horizontal" or "vertical" to add a new panel to picker view. This will return the panel id string.

-activePanelIndex(-api)

int

edit


Edit only flag, specify a panel index number, and the picker view will zoom and pan itself to frame the picker panel. A panel index is the number shown in [ ] in the title area of each picker panel.

-author(-ath)

string

queryedit


When queried, this flag returns a string of the picker author. In edit mode, specify a string to be the author of picker.

-close(-cl)

boolean

edit


Close the picker view, specify a boolean value of true to force close it even if the edits are not saved.

-email(-eml)

string

queryedit


When queried, this flag returns a string of the picker author's email. In edit mode, specify a string to be the email address of  picker.

The animator could use the email address to provide their feedback about your picker.

-exportPathToNode(-epn)

string string

edit


Export picker file path to a picker node. Bascially it store a file path to a picker file, in pickerFilePath attribute in picker node.

When picker node is loaded, the picker file will be loaded instead. The file path support environment variable denoted by $ or ${}

Specify the node name to export / edit and the picker file path as arguments.

-exist(-ex)

 

query


Return true or false the specify picker view id exists.

-fileVersion (-fv)

 

query


Query only. This flag return the file version of the picker view.

-getIdFromName (-gin)

string

query


Query only. Provided a name, return all the picker items that has the name in the picker view.

Even if there is only one match, it will still return a string array that contain only one element.

It is useful for avoiding hard-coding the id in your script, so you just use name to get the id, and do further picker item property query/edit.

-listLinks(-ll)

string

query


Query only flag. Return all the link IDs of a certain link type as a string array, in "sourceItemId > targetItemId" format;

Specify a type string as the argument,  values include "parentlink", "attributelink" (case-insensitive), you could specify empty string or "parentlink|attributelink" to return all types of links.

-list(-ls)

string

query


Query only flag. Return all the picker item IDs of a certain type as a string array.

Specify a type string as the argument,  values include "selectButton", "commandButton",  "attributeButton", "slider", "sliderHandle", "text", "panel" (case-insensitive),  a empty string will return all the picker item IDs.

The type string also support combination: say if you wanna list all select buttons and command buttons, you could use "selectButton|commandButton".

-mirrorSelection(-ms)

int

edit


Utilize the mirror relationship of picker items, mirror the scene selection in one of these mode:

0 = replace selection ,1 = add selection, 2 = deselect, 3 = invert selection.

-message(-msg)

string

edit


When queried, this flag returns a string of the picker author's message. In edit mode, specify a string to be the message of picker.

The picker designer use this to say something to all the animators who use this picker.

-namespaceChangedCommand(-ncc)

string script

queryedit


Query/edit the namespace changed command of picker file / node.

The namespace changed command will be executed after you changed the namespace of the picker view.

In query mode, this will return a string array, the first element is "mel/python" indicate the command type, the second element contains the actual command code.

In edit mode, specify the first argument "mel/python" and second argument the actual command code to edit the namespace changed command.

-namespace(-ns)

string

queryedit


When queried, this flag returns the picker's namespace. In edit mode, specify a string as the picker's namespace.

The string should obey to namespace naming convention, any invalid characters will be converted to '_'.

-pickerDirPath(-pdp)

 

query


This is a query only flag that can be used to query for the directory path name of the picker file.

-pickerEnterCommand(-pec)

string script

queryedit


Query/edit the mouse enter command of picker file / node.

The enter command will be executed whenever your mouse enter the picker view.

In query mode, this will return a string array, the first element is "mel/python" indicate the command type, the second element contains the actual command code.

In edit mode, specify the first argument "mel/python" and second argument the actual command code to edit the load command.

-pickerFilePath(-pfp)

 

query


This is a query only flag that can be used to query for the path name of the picker file.

-pickerLoadCommand(-plc)

string script

queryedit


Query/edit the load command of picker file / node.

The load command will be executed once after the picker file / node is loaded.

In query mode, this will return a string array, the first element is "mel/python" indicate the command type, the second element contains the actual command code.

In edit mode, specify the first argument "mel/python" and second argument the actual command code to edit the load command.

-removeAll(-ra)


edit


This is a edit only flag that can be used to clear all the content of the picker.

-remove(-ra)

string

edit


Edit only flag. Specify a picker item id to delete it from the view. Support multiple use in one single command.

-saveAs(-sa)

string boolean

edit


This is a edit only flag that can be used to save the picker file / node to another picker name. The saved picker file will be stored within the current picker project folder in the maya's user application directory / MG_PickerData.

Specify the target picker name and a boolean control whether or not override existed. Notice that the picker view id will stay unchanged.

-saveAsSceneNode(-sas)

string boolean

edit


This is a edit only flag that can be used to save picker file / node to another picker node,  specify a 0~1 boolean  value to indicate the picker view should be changed to refer to the saved node.

So 0 means exporting the picker node, 1 means save current picker as the target picker node. No matter what, it always override if the node already exists.

Notice that the picker view id will stay unchanged.

-saveAsTemplate(-sat)

string boolean

edit


This is a edit only flag that can be used to save picker file / node to picker template. Specify a picker template name to save to, a boolean value to control whether or not we override even the template already exist. If empty string is specified, a automatic template name will be used. Notice that the picker view id will stay unchanged.

-setClean(-sc)

 

edit


This is a edit only flag that can be used to mark the picker view as clean, this will remove the * sign from the tab.

-select(-sel)

string

queryeditmultiuse


In query mode, this returns the selected picker item IDs. In edit mode it is multi-usable, this perform picker item selection via IDs, you might need to use -selectMode to cooperate with this flag.

-selectPickerButtons(-skb)

int

edit


This is a edit only flag that can be used to eval all the select-buttons in picker, select their members in maya scene. This does not select related maya nodes from attribute buttons and sliders.

It is often used in the "Select All" command button. Use 0~3 int to specify the select mode:

0 = replace selection ,1 = add selection, 2 = deselect, 3 = invert selection.

-selectMode(-sm)

int

edit


This is a edit only flag that can be used to with -select falg to select picker items in picker view. Use 0~3 int to specify the select mode:

0 = replace selection ,1 = add selection, 2 = deselect, 3 = invert selection.

-selectPanelButtons(-spb)

int

edit


This is a edit only flag that can be used to eval all the select-buttons within picker panel, select their members in maya scene.

The command use current mouse position to decide which picker panel to eval all its children select-buttons.

It is often used in the "Select All" command button for picker panel. Use 0~3 int to specify the select mode:

0 = replace selection ,1 = add selection, 2 = deselect, 3 = invert selection.

-selectPanelIndexButtons(-spi)

int int

edit


This is a edit only flag that can be used to eval all the select-buttons within the picker panel with the panel index, select their members in maya scene. This does not select related maya nodes from attribute buttons and sliders.

It is often used in the "Select *" command button for picker panel. Use 0~3 int to specify the select mode:

0 = replace selection ,1 = add selection, 2 = deselect, 3 = invert selection.

You must specify a valid panel index int for the second argument.

-syncPickerValue(-spv)

 

edit


Sync all the picker items values with maya scene, in a programming approach. eg. attr-button value, slider values.

This will validate all sync-watchers for newly created nodes or loaded referenced nodes.

Usually this is done automatically when maya attribute changed.

-saveToFolder(-stf)

string boolean

edit


This is a edit only flag that can be used to save picker file / node within target directory. The saved picker file will be within target directory/pickername/ directory.

Specify a boolean to control a force override if file already exist. Notice that the picker view id will stay unchanged.

-saveWithinSceneFolder(-sws)

boolean

edit


This is a edit only flag that can be used to save picker file / node to current maya scene directory / pickers folder. This directory will be auto-searched for related picker file.

Specify a boolean to control a force override if file already exist. Notice that the picker view id will stay unchanged.

-tabLabel(-tl)

string

queryedit


In query mode, this return the tab label of current picker view.

In edit mode, this edit the tab label of current picker view, as well as the view's internal picker name.

-updateSceneBoundary(-usb)

 

edit


Update the picker scene display area boundary, to show all the picker items.

You may need to use this flag in the converter, after all picker item have been created.

-website(-www)

string

query


When queried, this flag returns the website of the current picker author. In edit mode, specify a string to be the website address of current picker.

The animator could visit the website to know more about the picker designer.

 


create Flag can appear in Create mode of command

edit Flag can appear in Edit mode of command

query Flag can appear in Query mode of command

multiuse Flag can be used more than once in a command.

MEL examples

// create a new picker named "myPicker"

string $view = `MGPicker -e -createPicker "myPicker" "wrongNamespace" "" ""`;   //it is a untitled picker, not refer to a picker file / node.

MGPickerView -e -namespace "rightNamespace" $view;          //edit the namespace of the picker.

 

//To-Do: use MGPickerItem command to created picker items.

//....

//if you does create any picker items, this picker view will be completely empty.

MGPickerView -e -author "Miguel" 

         -website "http://twincodes.com" 

         -email "mgpickerstudio@gmail.com"

         -message "Feel free to send feedback to me!" 

         $view;  //edit the meta info of the current picker file.

 

MGPickerView -e -updateSceneBoundary $view;  //update the scene boundary to show all the picker items.

MGPickerView -e -setClean $view;   //set the picker we just created clean.

Python examples

import maya.cmds as cmd
#Create a new picker named "myPicker"
#it is a untitled picker, not refer to a picker file / node.
viewId = cmds.MGPicker (edit=True,createPicker=("myPicker","wrongNamespace","",""))
cmds.MGPickerView(viewId, edit=True,namespace="rightNamespace")    #edit the namespace of the picker.

#To-Do: use MGPickerItem command to created picker items.
#....
#if you does create any picker items, this picker view will be completely empty.
cmds.MGPickerView(viewId, edit=True, author="Miguel",
                 website="http://twincodes.com",
                 email="mgpickerstudio@gmail.com",
                 message="Feel free to send feedback to me!")  #edit the meta info of the current picker file.
cmds.MGPickerView(viewId, edit=True, updateSceneBoundary=True)  #update the scene boundary to show all the picker items.
cmds.MGPickerView(viewId, edit=True, setClean=True)   #set the picker we just created clean.

 

Home Previous Next