MGPickerLink命令
MGPickerLink不可撤消, 可以查询且可以编辑。
这个命令创建, 查询或编辑一个picker连接。
跳转到: [MEL例子] [Python例子]
概要
MGPickerLink( exist=boolean, remove=boolean, source=string, target=string, targetValues=string, type=boolean, view=string, )
MGPickerLink命令 |
|---|
-exist(-ex)
|
这个标签只能用于查询模式,用来获取该连接是否存在。 |
-remove(-rm)
|
这个标签只能用于编辑模式,用来删除某个连接。 |
-source(-s) string
|
这个标签用于查询模式来获取该连接的源picker对象的id。 用在创建模式时,并必须同时指定-target标签来指定目标picker对象的id。这个标签不能用于编辑模式。 |
-target(-t) string
|
这个标签用于查询模式来获取该连接的目标picker对象的id。 用在创建模式时,并必须同时指定-source标签来指定源picker对象的id。这个标签不能用于编辑模式。 |
-targetValues(-tvs) string
|
这个标签用于查询模式来获取该连接的目标属性值,是一个字符窜数组。以决定什么样的值情况下,源picker对象才该被显示。 在创建 / 编辑模式,您必须指定一个字符窜数组作为参数,这个字符窜由多个数值用字符"," 连接而成。 |
-type(-typ)
|
这个标签只能用于查询模式,用来获取该连接的类别。 你不能再编辑一个连接的类型,因为它的连接类似是由目标picker对象决定的。 可能的数值有: |
-view(-v) string
|
控制要查询,编辑或创建在哪个picker视图的连接,在未使用该标签的情况下,默认是在当前激活的picker视图。 该标签需要您指定一个picker视图id字符窜。该id可以通过下方式来获取(具体请查询MGPicker命令参考文档): // 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;
|
标签可以在创建模式中使用;
标签可以在编辑模式中使用
标签可以在查询模式中使用
标签可以在一条命令中多次使用.
MEL例子
//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例子
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))