Home  Previous Next

命令 (MEL/Python)

MGPickerLink

跳转到: 概要. MEL例子. Python例子.

概要

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

MGPickerLink不可撤消, 可以查询且可以编辑

这个命令创建, 查询或编辑一个picker连接。

 

 

长名 (短名)

参数类型

属性

-exist(-ex)


query

 

这个标签只能用于查询模式,用来获取该连接是否存在。

-remove(-rm)


edit

 

这个标签只能用于编辑模式,用来删除某个连接。

-source(-s)

string

createquery

 

这个标签用于查询模式来获取该连接的源picker对象的id。

用在创建模式时,并必须同时指定-target标签来指定目标picker对象的id。这个标签不能用于编辑模式。

-target(-t)

string

createquery

 

这个标签用于查询模式来获取该连接的目标picker对象的id。

用在创建模式时,并必须同时指定-source标签来指定源picker对象的id。这个标签不能用于编辑模式。

-targetValues(-tvs)

string

createqueryedit

 

这个标签用于查询模式来获取该连接的目标属性值,是一个字符窜数组。以决定什么样的值情况下,源picker对象才该被显示。

在创建 / 编辑模式,您必须指定一个字符窜数组作为参数,这个字符窜由多个数值用字符"," 连接而成。

-type(-typ)

 

query

 

这个标签只能用于查询模式,用来获取该连接的类别。

你不能再编辑一个连接的类型,因为它的连接类似是由目标picker对象决定的。可能的数值有:"parentLink" 或 "attributeLink"。

-view(-v)

 

query

 

控制要查询,编辑或创建在哪个picker视图的连接,在未使用该标签的情况下,默认是在当前激活的picker视图。

该标签需要您指定一个picker视图id字符窜。该id可以通过下方式来获取(具体请查询MGPicker命名参考文档):

   MGPicker -q -currentPickerView;        // 获取当前所执行的脚本所属于的视图的id,如picker的加载命令和鼠标进入命令。仅脚本执行过程中可获取。

   MGPicker -q -activePickerView;         // 获取当前激活视图的id.

   MGPicker -q -findPickerView  "pickerNodeOrFileName"  1 "namespace";             // 通过指定picker节点或文件名来查找特定的picker视图id.

   MGPicker -q -listAllPickerViews;          // 列出所有打开的picker视图的id.

   MGPicker -e -createTempPicker;     // 创建一个临时picker视图并返回其id.

   MGPicker -e -createPicker "pickerName" "namespace" "filePath" "nodeName";        //创建一个picker视图并返回其id.

   MGPicker -e -readPickerNode "nodeName";       // 读取场景picker节点并返回其所打开的picker视图的id.

   MGPicker -e -readScenePicker "nodeName" "pickerName" "namespace" "pickerDataString";       // 读取场景picker节点并返回其所打开的picker视图的id.

   MGPicker -e -readPickerFile "pickerFilePath" 1;         // 读取picker文件并返回其所打开的picker视图的id.


create 标签可以在创建模式中使用

edit 标签可以在编辑模式中使用

query 标签可以在查询模式中使用

multiuse 标签可以在一条命令中多次使用

MEL例子

//You must make sure the picker item: selectButton1, selectButton2, attributeButton1 are alreay 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')                                                  
print ("The type for the link \""+newParentLink+"\" is: "+ mgp.MGPickerLink(newParentLink, q=True,type=True) + ".\n")

#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 linked and controlled by the item attributeButton1 at values: \n")
print (mgp.MGPickerLink(newAttrLink,q=True,targetValues=True))

Home Previous Next