Home  Previous Next

command (MEL/Python)

MGPickerItem

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

MEL Synopsis

MGPickerItem [-applyMirroredAttribute] [-annotation] [-addSelectMember] [-attributeType] [-attribute] [-attributeValue] [-bgHorizontalAlign] [-backgroundImage] [-bgKeepRatio] [-bgMargin] [-boolState] [-bgScaleFit] [-bevel] [-bgVerticalAlign] [-command] [-closeCurve] [-clearSelectMembers] [-commandType] [-componentWidth] [-componentWidthPolicy] [-drawBGRect] [-drawBackgroundShape] [-exist] [-fillColor] [-frameColor] [-frameVisible] [-fullNamespace] [-floatState] [-gradient] [-gradientMode] [-height] [-highlightImage] [-hoverLightness] [-image] [-interactive] [-imageMargin] [-intState] [-label] [-labelBold] [-labelColor] [-labelFont] [-labelFontSize] [-labelHorizontalAlign] [-labelItalic] [-links] [-labelPosition] [-leftSlope] [-labelVerticalAlign] [-masterButtons] [-mirror] [-name] [-opacity] [-parent] [-postAction] [-pressedImage] [-postChangeCommand] [-postChangeCommandType] [-preChangeCommand] [-preChangeCommandType] [-rotation] [-roundness] [-resizePreferSize] [-removeSelectMember] [-rightSlope] [-shape] [-slaveButtons] [-strokeColor] [-sliderChangeCommand] [-sliderChangeCommandType] [-shapeDirection] [-select] [-sliderHAttribute] [-sliderHMin] [-sliderHRange] [-sliderHSpeed] [-sliderHMax] [-showItemTip] [-selectMembers] [-subNamespace] [-stringState] [-sliderVAttribute] [-sliderVMin] [-sliderVRange] [-sliderVSpeed] [-sliderVMax] [-strokeWidth] [-type] [-usePickerNamespace] [-view] [-valueColor] [-visible] [-visibilityOperator] [-width] [-xPosition] [-yPosition] itemIDString

Python Synopsis

MGPickerItem (itemIdString, [applyMirroredAttribute=boolean], [annotation=string],  [addSelectMember=string], [attributeType=string], [attribute=string], [attributeValue=float], [bgHorizontalAlign=string], [backgroundImage=string], [bgKeepRatio=boolean], [bgMargin=[int, int, int, int]], [boolState=[boolean]], [bgScaleFit=boolean], [bevel=boolean], [bgVerticalAlign=string], [command=string], [closeCurve=boolean], [clearSelectMembers=boolean], [commandType=string], [componentWidth=int], [componentWidthPolicy=string], [drawBGRect=boolean], [drawBackgroundShape=boolean], [exist=boolean], [fillColor=[float, float, float, float]], [frameColor=[float, float, float, float]], [frameVisible=boolean], [fullNamespace=boolean], [floatState=float], [gradient=boolean], [gradientMode=int], [height=int], [highlightImage=string], [hoverLightness=int],[image=string], [interactive=boolean], [imageMargin=[int, int, int, int]], [intState=[int]], [label=string], [labelBold=boolean], [labelColor=[float, float, float, float]], [labelFont=string], [labelFontSize=int], [labelHorizontalAlign=string], [labelItalic=boolean], [links=boolean], [labelPosition=string], [leftSlope=int], [labelVerticalAlign=string], [masterButtons=boolean], [mirror=string],[name=string], [opacity=float], [parent=string], [postAction=string], [pressedImage=string], [postChangeCommand=string], [postChangeCommandType=string], [preChangeCommand=string], [preChangeCommandType=string], [rotation=int], [roundness=int], [resizePreferSize=boolean], [removeSelectMember=string], [rightSlope=int], [shape=boolean], [slaveButtons=boolean], [strokeColor=[float, float, float, float]], [sliderChangeCommand=string], [sliderChangeCommandType=string], [shapeDirection=string], [select=int], [sliderHAttribute=string],[sliderHMin=float], [sliderHRange=boolean], [sliderHSpeed=float], [sliderHMax=float],[showItemTip=string],  [selectMembers=string],[subNamespace=string], [stringState=string], [sliderVAttribute=string], [sliderVMin=float], [sliderVRange=boolean], [sliderVSpeed=float], [sliderVMax=float], [strokeWidth=int], [type=string], [usePickerNamespace=boolean], [view=string], [valueColor=[float, float, float, float]], [visible=boolean], [visibilityOperator=string], [width=int], [xPosition=int], [yPosition=int])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

MGPickerItem is NOT undoable, queryable, and editable.

This command create / queries / edit a picker item, currently this include select-button, command-button, attribute-button, slider, text and panel.

Specify -view flag and a picker view id string if the picker item is not in current active picker view.

Some flags only make sense to a certain type of picker item, but it is ok to apply to unsupported picker item type, which just has no effect.

Return value

Return the picker item id in creation / edit mode, all types of value in query mode.

Flags

applyMirroredAttribute, annotation, addSelectMember, attributeType, attribute, attributeValue, bgHorizontalAlign, backgroundImage, bgKeepRatio, bgMargin, boolState, bgScaleFit, bevel, bgVerticalAlign, command, closeCurve, clearSelectMembers, commandType, componentWidth,componentWidthPolicy, drawBGRect, drawBackgroundShape, exist, fillColor, frameColor, frameVisible, fullNamespace, floatState, gradient, gradientMode, height, highlightImage, hoverLightness, image, interactive, imageMargin, intState, label, labelBold, labelColor, labelFont, labelFontSize, labelHorizontalAlign, labelItalic, links, labelPosition, leftSlope, labelVerticalAlign, masterButtons, mirror, name, opacity, parent, postAction, pressedImage, postChangeCommand, postChangeCommandType, preChangeCommand, preChangeCommandType, rotation, roundness, resizePreferSize, removeSelectMember, rightSlope, shape, slaveButtons, strokeColor, sliderChangeCommand, sliderChangeCommandType, shapeDirection, select, sliderHAttribute, sliderHMin, sliderHRange, sliderHSpeed, sliderHMax, showItemTip, selectMembers, subNamespace, stringState, sliderVAttribute, sliderVMin, sliderVRange, sliderVSpeed, sliderVMax, strokeWidth, type, usePickerNamespace, view, valueColor, visible, visibilityOperator, width, xPosition, yPosition

 

Long name (short name)

Argument types

Properties

-applyMirroredAttribute(-ama)

 

edit


Apply mirrored attribute values to its mirrored item, attribute values such as color, size, shape will be copied as is, yet some attributes will be mirrored, such as "labelHorizontalAlign" will be mapped between "left" and "right", position and rotation will be mirrored, etc. If no mirror item then a warning will be issued.

-annotation(-ann)

string

createqueryedit


The tool tip text for the item, will be shown when you hover mouse over the item.

-addSelectMember(-asm)

string

createeditmultiuse


Only makes sense for select-button. Append a node to the select-button's member list.

-attributeType(-atp)

string

createqueryedit


Only makes sense for attribute-button. Return the attribute type of the attribute button in query mode, possible values are  "bool", "enum", "maya", which means "dummy bool attribute button", "dummy enum attribute button" and "maya attribute button". In creation and edit mode, this changes the attribute button's attribute type. In creation mode, if this flag is absent then by default the attribute button will be a dummy bool attribute button, which has a bool type attribue but doesn't control any maya attribute.

-attribute(-att)

string

createqueryedit


Only makes sense for attribute-button. Return namespace:node.attribute in query mode if it is a maya attribute button, or else return empty string.

In creation / edit mode, you need to specify a node.attribute string as argument for a maya attribute button, for a dummy enum attribute button, you assign enum value strings connected with ":" character, "Proxy:LoRes:HiRes" for example. For a dummy bool attribute button this flag doesn't make any sense since a dummy bool attribute always have "on/off" value.

-attributeValue(-atv)

float

createqueryedit


Only makes sense for attribute-button. Return current attribute value as float in query mode, set the attribute value in creation / edit mode.

-bgHorizontalAlign(-bha)

string

createqueryedit


Only makes sense for picker panel. The horizontal alignment of the background image as it is fill in the content area of picker panel.

Valid values are "center", "left", "right".

-backgroundImage(-bi)

string

createqueryedit


Only makes sense for picker panel. The background image used in picker panel.

-bgKeepRatio(-bkr)

boolean

createqueryedit


Only makes sense for picker panel. When background image scale itself to fit in the picker panel content area, if this option is on, it will keep the width/height ratio while scaling.

-bgMargin(-bmg)

int int int int

createqueryedit


Only makes sense for picker panel. The left, right, top, bottom margin for the background image to the picker panel content area's corresponding edge.

Depending the background image alignment specified by -bgHorizontalAlign/-bha and -bgVerticalAlign/-bva, only 0~3 components of the margin may take effect.

-boolState(-bs)

boolean

createqueryedit


For programming purpose only. Used to store a boolean state value with a certain picker item.

Usually you need it when toggle the state of a command-button. (Click to switch on, again to switch off, etc.)

A bool/float/int/string state value is not undoable, yet they are savable in the picker file/node.

-bgScaleFit(-bsf)

boolean

createqueryedit


Only makes sense for picker panel. If background image should scale itself to fit in the picker panel content area.

-bevel(-bv)

boolean

createqueryedit


Whether the item should be drawn in bevel style.

-bgVerticalAlign(-bva)

string

createqueryedit


Only makes sense for picker panel. The vertical alignment of the background image as it is fill in the content area of picker panel.

Valid values are "center", "top", "bottom".

-command(-c)

script

createqueryedit


Only makes sense for command-button. The mel / python codes been executed when the command-button is pressed and released.

-closeCurve(-ccv)

boolean

createqueryedit


Only makes sense when the item uses a bezier shape. Determine if the bezier curve should be closed automatically or not.

-clearSelectMembers(-csm)

 

createedit


Only makes sense for select-button. Clear the select-button's member list.

-commandType(-ct)

string

createqueryedit


Only makes sense for command-button. Set the language type of the command-button command.

Valid values are "mel", "python".

-componentWidth(-cw)

int

createqueryedit


Only makes sense for attribute-button. This flag set / query the value field width, the component width only works when componentWidthPolicy set to "fixed".

-componentWidthPolicy(-cwp)

string

createqueryedit


Only makes sense for attribute-button. It controls the value field width policy, valid values are  "stretch" and  "fixed". By default policy is "stretch", so value field will be as wide as possible as long as the label field could display all the label. Setting policy to "fixed" will force the value field be a fixed width, it is useful when you line up multiple attribute-buttons vertically, and wanna the separate lines of label & value field also be lined up vertically like Maya channelbox. All you need is just set their policies to "fixed", and use the same component width on all these attribute-buttons.

-drawBGRect(-dbr)

boolean

createqueryedit


Only makes sense for text item. If the background rectangle should be drawn as the text's background or not.

-drawBackgroundShape(-dbs)

boolean

createqueryedit


Only makes sense when the item uses a image shape. Determine if the background rectange should be drawn as the background of the image or not.

-exist(-ex)

 

createqueryedit


Query only flag, test if the certain picker item id exists or not.

-fillColor(-fc)

float float float float

createqueryedit


The fill color of the item. Arguments are red, green, blue, alpha float values range [0~1].

-frameColor(-fmc)

float float float float

createqueryedit


Only makes sense for picker panel and slider.

The frame color of the items. Arguments are red, green, blue, alpha float values range [0~1].

-frameVisible(-fmv)

boolean

createqueryedit


Only makes sense for picker panel and slider.

Determine if the panel should draw its frame, or a slider should draw its background slot.

-fullNamespace(-fns)

 

query


Query only flag that only makes sense for select-button, command-button, attr-button and slider. it returns the full namespace of the maya nodes containes in the picker item, which is, "PickerNamespace:SubNamespace", if subNamespace is empty then only the picker view namespace will be returned, eg. "PickerNamespace".

Picker items like select-button, attr-button and slider only record maya node name without any namespace, the actual namespace will be composed of picker namespace of the picker view and sub-namespace of current picker item, which means,

the maya node actually be selected / manipulated is PickerNamespace:SubNamespace:nodeName.

-floatState(-fs)

float

createqueryedit


For programming purpose only. Used to store a float data with a certain picker item.

A bool/float/int/string state value is not undoable, yet they are savable in the picker file/node.

-gradient(-gd)

boolean

createqueryedit


Determine if the item should be fill with slight gradient based on the fill color.

-gradientMode(-gdm)

int

createqueryedit


The direction of the gradient fill. Valid values are  0 / 1.

For 0 the gradient will go from top to bottom, 1 will go from bottom to top.

-height(-h)

int

createqueryedit


The height of the picker item in pixels.

-highlightImage(-hi)

string

createqueryedit


Only makes sense when it is a select-button uses a image shape. The image used when the select-button is highlight due to its members been partially or totally selected in maya scene.

-hoverLightness(-hl)

int

createqueryedit


Apply to all kinds of picker item, specify -10~10 int value for the argument, negative value means picker item become darker when mouse hover onto it, positive value means becoming lighter.

-image(-i)

string

createqueryedit


Only makes sense when the picker item uses a image shape. The image used by the item.

-interactive(-iac)

boolean

createqueryedit


Determine if a picker item should response to a mouse clicking.

A text item is by default not interactive.

-imageMargin(-img)

int int int int

createqueryedit


Only makes sense when a picker item uses a image shape. It determines how the image be placed in the item.

The left, right, top, bottom margin for the image to the item's corresponding edge.

Depending the label alignment specified by -labelHorizontalAlign/-lha and -labelVerticalAlign/-lva, only 0~3 components of the margin may take effect.

-intState(-is)

int

createqueryedit


For programming purpose only. Used to store an int data with a certain picker item.

A bool/float/int/string state value is not undoable, yet they are savable in the picker file/node.

-label(-l)

string

createqueryedit


The label of the picker item.

-labelBold(-lb)

boolean

createqueryedit


If the label font should adopt the bold style.

-labelColor(-lc)

float float float float

createqueryedit


The color of the label. Arguments are red, green, blue, alpha float values range [0~1].

-labelFont(-lf)

string

createqueryedit


The font of the label.

-labelFontSize(-lfs)

int

createqueryedit


The font size of the label in pixels.

-labelHorizontalAlign(-lha)

string

createqueryedit


The horizontal alignment of the label to its item.

Valid values are "center", "left", "right".

-labelItalic(-li)

boolean

createqueryedit


If the label font should adopt the italic style.

-links(-lks)

 

query


This is a query only flag that can be used to get all the link ids related to current picker item.

-labelPosition(-lp)

string

createqueryedit


Only makes sense for slider. How label be layout with the slider. Valid values are  "top", "bottom", "left", "right".

-leftSlope(-lsp)

int

createqueryedit


Only makes sense when a picker item uses a trapezoid shape.

The left slope value for the trapezoid, ranges [-10~10].

-labelVerticalAlign(-lva)

string

createqueryedit


The vertical alignment of the label to its item.

Valid values are "center", "top", "bottom".

-masterButtons(-mbs)

 

query


Query only flag to return the master buttons of this picker item, e.g. The attribute buttons that are controlling the visibility of current picker item, or parent select-buttons of current select-button.

-mirror(-mrr)

string

createqueryedit


In query mode this return the mirrored item id for current picker item.

In create / edit mode this set the item id as the mirrored item for current picker item.

-name(-n)

string

createqueryedit


Query/edit the name of the picker item.

Name property is solely used to avoid hard-coding the id durning picker programming.

You can use "MGPicker -q -getIdFromName name" to get the id from this name, so further edit/query could be processed based on that id.

-opacity(-op)

float

createqueryedit


The opacity of the picker item's fill color, value ranges [0~1], which will be mapped to [0~20]  real opacity int value  for the item.

-parent(-p)

string

createqueryedit


The parent picker panel id of current picker item.

In create / edit mode you should specify a valid picker panel id, specify a empty panel id to unparent the picker item from any parent panel.

-postAction(-pa)

string

createqueryedit


Only makes sense for select-button. What tool should be switched to automatically after the select-button is pressed.

Valid values are  "nothing", "translate", "rotate", "scale".

-pressedImage(-pi)

string

createqueryedit


Only makes sense when a picker item uses a image shape. The image used when the item is pressed by mouse button.

-postChangeCommand(-poc)

script

createqueryedit


Only makes sense for attribute-button. The mel / python command be executed after the attribute button value been changed in picker view.

-postChangeCommandType(-pot)

string

createqueryedit


Only makes sense for attribute-button. The language type for the post change command of a attribute-button.

Valid values are "mel", "python".

-preChangeCommand(-prc)

script

createqueryedit


Only makes sense for attribute-button. The mel / python command be executed before the attribute button value be changed  in picker view.

-preChangeCommandType(-prt)

string

createqueryedit


Only makes sense for attribute-button. The language type for the pre change command of a attribute-button.

Valid values are "mel", "python".

-rotation(-r)

int

createqueryedit


Only makes sense for select-button which uses shapes other than polygon and bezier shape.

The rotation value of the select-button, ranges [-180~180].

-roundness(-rd)

int

createqueryedit


Only makes sense for items which uses shapes that support this attribute.

The roundness of the shape. The value ranges [0~100].

-resizePreferSize(-rps)

 

createedit


Resize the picker item to its proper size. If the -width/-w or -height/-h flags are specified, this flag will be ignored.

-removeSelectMember(-rsm)

string

createeditmultiuse


Only makes sense for select-button. Remove a node from the select-button's member list.

-rightSlope(-rsp)

int

createqueryedit


Only makes sense when a picker item uses a trapezoid shape.

The right slope value for the trapezoid, ranges [-10~10].

-shape(-s)

string

createqueryedit


The shape for the picker item. If you specify a shape type that the picker item doesn't support, this flag has no effect.

Valid values are "rectangle", "roundedRectangle", "ellipse", "circle", "triangle", "diamond", "trapezoid", "pentagon", "hexagon", "polygon", "bezier", "image", "widgetControl", "attributeButton", "roundedAttriuteButton", "slider".

Notice that different type of picker item support different range of shapes, refer to shape drop-down menu of  attribute editor in MG-Picker Studio to know more.

-slaveButtons(-sbs)

 

query


Query only flag to return the slave buttons of this picker item, e.g. The picker items that are control but current attribute button, or child select-buttons of current select-button.

-strokeColor(-sc)

float float float float

createqueryedit


The color of the stroke. Arguments are red, green, blue, alpha float values range [0~1].

-sliderChangeCommand(-scc)

script

createqueryedit


Only makes sense for slider.The command be executed when the slider value changed  in picker view or by the attribute nudger.

-sliderChangeCommandType(-sct)

string

createqueryedit


Only makes sense for slider. The language type for the change command of a slider.

-shapeDirection(-sd)

string

createqueryedit


Only makes sense for items which uses shapes that support this attribute.

Valid values are "top", "bottom", "left", "right".

-select(-sel)

int

createqueryedit


In edit mode this select the picker item. Specify a 0~3 int as the selection mode:

 0 for replace selection,

 1 for add selection,

 2 for deselect,

 3 for toggle selection

In query mode, this will return 0/1 indicates that the picker item is currently selected or not.

-sliderHAttribute(-sha)

string

createqueryedit


Only makes sense for slider. The attribute controlled by slider in horizontal direction. Specify node.attribute in create / edit mode.

Notice that both the node and attribute should exist at the moment.

-sliderHMin(-shi)

float

createqueryedit


Only makes sense for slider. The software minimum value of the horizontal attribute. It is used by picker, does not affect maya attribute value range.

-sliderHRange(-shr)

boolean

createqueryedit


Only makes sense for slider. Decide whether or not we use the software range for horizontal attribute.

-sliderHSpeed(-shs)

float

createqueryedit


Only makes sense for slider. The speed float for the horizontal attribute. Ranges in [-1, 1], and can't be zero.

-sliderHMax(-shx)

float

createqueryedit


Only makes sense for slider. The software maximum value of the horizontal attribute. It is used by picker, does not affect maya attribute value range.

-showItemTip(-sit)

string

edit


Pop up a tip showing the specified text at the position of the item. If you specify empty string, then it will show the picker item's note string instead (MGPickerItem -q -annotation).

If note string is also empty, then it won't pop up anything.

-selectMembers(-sms)

string

createqueryedit


Only makes sense for select-button. Set a string array as the select-button's member list.

In query mode this return a string array, in create / edit mode you should specify a string contains all the member nodes and joined using space character.

Specify empty string to clear the select member list.

-subNamespace(-sns)

string

createqueryedit


Query/edit the sub-namespace of the picker item.

For now it only works to select-button, command-button, attr-button and slider, makes no sense for picker panel, text.

It is used to support the reference based rigging architecture, which contains layered namespace in nature. Check out here for more information.                        

-stringState(-ss)

string

createqueryedit


For programming purpose only. Used to store a string data with a certain picker item.

A bool/float/int/string state value is not undoable, yet they are savable in the picker file/node.

-sliderVAttribute(-sva)

string

createqueryedit


Only makes sense for slider. The attribute controlled by slider in vertical direction. Specify node.attribute in create / edit mode.

Notice that both the node and attribute should exist at the moment.

-sliderVMin(-svi)

float

createqueryedit


Only makes sense for slider. The software minimum value of the vertical attribute. It is used by picker, does not affect maya attribute value range.

-sliderVRange(-svr)

boolean

createqueryedit


Only makes sense for slider. Decide whether or not we use the software range for vertical attribute.

-sliderVSpeed(-svs)

float

createqueryedit


Only makes sense for slider. The speed float for the vertical attribute. Ranges in [-1, 1], and can't be zero.

-sliderVMax(-svx)

float

createqueryedit


Only makes sense for slider. The software maximum value of the vertical attribute. It is used by picker, does not affect maya attribute value range.

-strokeWidth(-sw)

int

createqueryedit


The width of the stroke in pixel, ranges [0~10], the value 0 means no stroke.

-type(-typ)

string

createquery


In query mode this flag returns the type string of the picker item.

You must specify this flag when you are in create mode to create a picker item.

Valid values are "selectButton", "commandButton", "attributeButton", "slider", "text", "panel". They are all case-insensitive;

If the type string is invalid, by default will create a select-button.

-usePickerNamespace(-upn)

boolean

createqueryedit


By default the property value is true. In query mode this flag returns whether or not the maya node name in this picker item will use picker's namespace when it comes evaluating.  e.g. The node member of select-button, attribute button and slider. In edit mode this sets the property.

When user clicks on a select button, the final maya node it select is as follow (Same rules apply to attribute button and slider):

 

NodeName in Button

Picker Namespace

Button Sub-Namespace

Button uses Picker Namespace

Final Maya Node to Select

pCube

pickerNS

 

Yes

pickerNS:pCube

pCube

pickerNS

 

No

pCube

pCube

pickerNS

subNS

Yes

pickerNS:subNS:pCube

pCube

pickerNS

subNS

No

subNS:pCube

myChar:pCube

pickerNS

 

Yes

myChar:pCube

myChar:pCube

pickerNS

 

No

myChar:pCube

myChar:pCube

pickerNS

subNS

Yes

myChar:pCube

myChar:pCube

pickerNS

subNS

No

myChar:pCube

 

-view(-v)

string

createqueryedit


This controls which picker view that the picker item belongs to, if this flag is not specified, then current view will be used by default. A picker view id string should be specified for this flag in query, create, edit mode.

The picker view id could be retrieved by MGPicker commands such as:  (Please refer to MGPicker command manual for further details.)

   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.

-valueColor(-vc)

float float float float

createqueryedit


Only makes sense for attribute-button and slider. For attribute-button this is the color of the value text, for slider this is the color rectangle been drawn to show how current value be varied from  its default value.Arguments are red, green, blue, alpha float values range [0~1].

-visible(-vis)

boolean

createqueryedit


The visibility of the picker item.

-visibilityOperator(-vis)

string

createqueryedit


The visibility operator, when picker item is controlled by multiple attribute buttons.

Specify "and", means all attribute buttons should meet the values,  then picker item is visible.

Specify "or" means any one of attribute buttons meet the value, then picker item is visible.

-width(-w)

int

createqueryedit


The wdith of the picker item in pixels.

-xPosition(-x)

int

createqueryedit


The x coordinate of the picker item in pixels.

-yPosition(-y)

int

createqueryedit


The y coordinate of the picker item in pixels.


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 pCube1 if not exists:
if(!`objExists pCube1`)
{
    polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1;
}

// create a new picker named "myPicker"
string $viewId = `MGPicker -e -createPicker "myPicker" "wrongNamespace" "" ""`;   //it is a untitled picker, not refer to a picker file / node.
MGPickerView -e -namespace "" $viewId;          //set the namespace to empty string.

//create picker panel first:
string $panel = `MGPickerItem -view $viewId -type "panel" -label "Panel1" -frameColor .2 .2 .22 1 -x 0 -y 0 -w 400 -h 300`;

//create other items:
string $selButton = `MGPickerItem -view $viewId -type "selectButton" -p $panel
                                        -x 20 -y 20 -w 100 -h 20 -shape "roundedRectangle" 
                                       -l "Select Button"
                                        -selectMembers "pCube1"`;
string $commandButton = `MGPickerItem -view $viewId -type "commandButton" 
                                                -p $panel 
                                                -x 20 -y 50 -w 100 -h 20 
                                                -l "Cmd Button"
                                                -c ("print (\"Current button is: \\\"\"+`MGPicker -q -currentItem`+\"\\\".\\n\")")`;
string $slider = `MGPickerItem -view $viewId -type "slider" -p $panel
                                -sliderHAttribute "pCube1.translateX"
                                -sliderVAttribute "pCube1.translateY"
                                -l "pCube:tx-ty"
                                -x 23 -y 100 -w 100 -h 100`;
string $attributeButton = `MGPickerItem -view $viewId -type "attributeButton" 
                                                -attributeType "bool"
                                           -l "Toggle" 
                                                -p $panel
                                                -valueColor .1 .5 .5 1
                                                -x 200 -y 35 -w 100 -h 20`;
string $text = `MGPickerItem -view $viewId -p $panel -type "text" -x 200 -y 80 -labelFontSize 11
                                -l "The attribute button\ncontrols the select-button,\ncommand-button and the slider." 
                               -resizePreferSize`;        

//link the visibilities of select-button and command-button to attribute "on":
string $link1 = `MGPickerLink -view $viewId -s $selButton -t $attributeButton -targetValues "on"`;
string $link2 = `MGPickerLink -view $viewId -s $commandButton -t $attributeButton -targetValues "on"`;
string $link3 = `MGPickerLink -view $viewId -s $slider -t $attributeButton -targetValues "on"`;

//turn the value of attribute-button to On to show the buttons:
MGPickerItem -e -view $viewId -attributeValue 1 $attributeButton;

MGPickerView -e -updateSceneBoundary $viewId;  //update the scene boundary to show all the picker items.
MGPickerView -e -setClean $viewId;   //set the picker we just created clean.

Python examples
 
import maya.cmds as cmd

#create pCube1 if not exists:
if not cmd.objExists('pCube1'):
   cmd.polyCube (w=1, h=1,d=1,sx=1,sy=1,sz=1,ax=(0,1,0), cuv=4,ch=1)

# create a new picker named "myPicker"
#it is a untitled picker, not refer to a picker file / node.
viewId = cmd.MGPicker (edit=True, createPicker=("myPicker","wrongNamespace","",""))
cmd.MGPickerView(viewId, edit=True, namespace="")        #set the namespace to empty string.

#create picker panel first:
panel = cmd.MGPickerItem(view=viewId, type="panel",label="Panel1",frameColor=(.2,.2,.2,1), x=0,y=0,w=400,h=300)

#create other items:
selButton = cmd.MGPickerItem(view=viewId, type="selectButton",p=panel,
                                     x=20,y=20,w=100,h=20,shape="roundedRectangle",
                                     l="Select Button",
                                     selectMembers="pCube1")

commandButton = cmd.MGPickerItem (view=viewId, type="commandButton",
                                             p=panel,
                                             x=20,y=50,w=100,h=20,
                                             l="Cmd Button",
                                             c=("print (\"Current button is: \\\"\"+`MGPicker -q -currentItem`+\"\\\".\\n\")"))

slider = cmd.MGPickerItem(view=viewId, type="slider",p=panel,
                             sliderHAttribute="pCube1.translateX",
                             sliderVAttribute="pCube1.translateY",
                             l="pCube:tx-ty",
                             x=23,y=100,w=100,h=100)

attributeButton = cmd.MGPickerItem (view=viewId, type="attributeButton",
                                             attributeType="bool",
                                         l="Toggle",
                                             p=panel,
                                             valueColor=(.1,.5,.5,1),
                                             x=200,y=35,w=100,h=20)

text = cmd.MGPickerItem (view=viewId, p=panel, type="text",x=200,y=80,labelFontSize=11,
                             l="The attribute button\ncontrols the select-button,\ncommand-button and the slider.",
                             resizePreferSize=True)      

#link the visibilities of select-button and command-button to attribute "on":
link1 = cmd.MGPickerLink (view=viewId, s=selButton,t=attributeButton,targetValues="on")
link2 = cmd.MGPickerLink (view=viewId, s=commandButton ,t=attributeButton,targetValues="on")
link3 = cmd.MGPickerLink (view=viewId, s=slider ,t=attributeButton,targetValues="on")

#turn the value of attribute-button to On to show the buttons:
cmd.MGPickerItem (attributeButton, edit=True, view=viewId, attributeValue=1)
cmd.MGPickerView (viewId, edit=True,updateSceneBoundary=True)  #update the scene boundary to show all the picker items.
cmd.MGPickerView (viewId, edit=True,setClean=True)  #set the picker we just created clean.

 

Home Previous Next