Home  Previous Next

command (MEL/Python)

MGPickerLink

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

MEL Synopsis

MGPickerLink [-exist] [-remove] [-source] [-target] [-targetValues] [-type] [-view] linkIDString

Python Synopsis

MGPickerLink (linkIDString, [exist=boolean] [remove=boolean] [source=string] [target=string] [targetValues=string] [type=boolean]) [view=string])

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

MGPickerLink is NOT undoable, queryable, and editable.

This command create / queries / edit picker links.

Return value

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

Flags

exist, remove, source, target, targetValues, type, view

 

Long name (short name)

Argument types

Properties

-exist(-ex)


query


This is a query only flag that can be used to query for the existence of a specific link.

-remove(-rm)


edit


This is a edit only flag that can be used to remove a specific link.

-source(-s)

string

createquery


If queried this flag will return the source picker item id.

The flag can't be used in edit mode, and you must use it with -target flag to both assign a source & target picker item id.

-target(-t)

string

createquery


If queried this flag will return the target picker item id.

The flag can't be used in edit mode, and you must use it with -source flag to both assign a source & target picker item id.

-targetValues(-tvs)

string

createqueryedit


If queried this flag will return all the target values as string array.

In creation / edit mode, you must assign a string value as the argument, the string is all the target value strings join by "," character.

-type(-typ)

 

query


This is a query only flag that can be used to query for the type of a specific link.

You can't edit the type of the link using this flag, since the type is auto-decided by the source & target picker items.

The possible type string are  "parentLink" or "attributeLink".

-view(-v)

string

createqueryedit


This controls which picker view that the link 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.


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

//You must make sure the picker item: selectButton1, selectButton2, attributeButton1 are already in scene in order to test these codes.
//link two select-buttons with parent link.
//for select-button, the target attribute value flag makes no sense.
//you don't want to assign a custom link name here, since it is always sourcePickerItemName>targetPickerItemName.        
string $newParentLink = `MGPickerLink -s selectButton1 -t selectButton2`;                                                   
print ("The type for the link \""+$newParentLink+"\" is: "+`MGPickerLink -q -type $newParentLink` + ".\n");

//link seelct-button to a attribute button, a attribute-link will be created.
string $newAttrLink = `MGPickerLink -s "selectButton1" -t "attributeButton1" -targetValues "Green,Red"`;
print "The item selectButton1 is linked and controlled by the item attributeButton1 at values: \n";
print `MGPickerLink -q -targetValues $newAttrLink`;

Python examples

import maya.cmds as cmd

#You must make sure the picker item: selectButton1, selectButton2, attributeButton1 are already in scene in order to test these codes.
#link two select-buttons with parent link.
#for select-button, the target attribute value flag makes no sense.
#you don't want to assign a custom link name here, since it is always sourcePickerItemName>targetPickerItemName.        
newParentLink = cmd.MGPickerLink(s='selectButton1',t='selectButton2')                                                  
print ("The type for the link \""+newParentLink+"\" is: "+ cmd.MGPickerLink(newParentLink, q=True,type=True) + ".\n")

#link seelct-button to a attribute button, a attribute-link will be created.
newAttrLink = cmd.MGPickerLink(s='selectButton1',t='attributeButton1',targetValues='Green,Red')
print ("The item selectButton1 is linked and controlled by the item attributeButton1 at values: \n")
print (cmd.MGPickerLink(newAttrLink,q=True,targetValues=True))

Home Previous Next