MGPickerLink
MGPickerLink is NOT undoable, queryable, and editable.
This command creates / queries / edits picker links.
Go to: [MEL Examples] [Python Examples]
Synopsis
MGPickerLink( exist=boolean, remove=boolean, source=string, target=string, targetValues=string, type=boolean, view=string, )
MGPickerLink |
|---|
-exist(-ex)
|
This is a query only flag that can be used to query for the existence of a specific link. |
-remove(-rm)
|
This is a edit only flag that can be used to remove a specific link. |
-source(-s) string
|
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
|
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
|
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)
|
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
|
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.) // Get current script execution view id,
// eg. picker load command, picker mouse enter command.
// This is only set during the script being executed.
MGPicker -q -currentPickerView;
// Get current active view id.
MGPicker -q -activePickerView;
// Find picker view id via picker node name or picker file name and namespace.
MGPicker -q -findPickerView "pickerNodeOrFileName" 1 "namespace";
// List ids of all opened picker views.
MGPicker -q -listAllPickerViews;
// Create a temporary picker view and return its id.
MGPicker -e -createTempPicker;
// Create a picker view and return its id.
MGPicker -e -createPicker "pickerName" "namespace" "filePath" "nodeName";
// Read in-scene picker node 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 a picker file and return its id.
MGPicker -e -readPickerFile "pickerFilePath" 1;
|
Flag can appear in Create mode
Flag can appear in Edit mode
Flag can appear in Query mode
Flag can be used more than once.
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
from mgpicker import mgp
# 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 = mgp.MGPickerLink(s="selectButton1", t="selectButton2")
linkType = mgp.MGPickerLink(newParentLink, q=True, type=True)
print('The type for the link "{}" is: {}.\n'.format(newParentLink, linkType))
# link seelct-button to a attribute button, a attribute-link will be created.
newAttrLink = mgp.MGPickerLink(
s="selectButton1", t="attributeButton1", targetValues="Green,Red"
)
print("The item selectButton1 is controlled by the item attributeButton1 at values: \n")
print(mgp.MGPickerLink(newAttrLink, q=True, targetValues=True))