MGPickerViewRegion命令

MGPickerViewRegion is NOT undoable, queryable, and editable.

这个命令创建, 查询或编辑一个picker视图区域。

跳转到: [MEL例子] [Python例子]

MGPickerViewRegion命令

-activate(-act)C E A

用于平稳缩放picker视图,以聚集到该视图区域。 该动作支持动画。

-animation(-ani)int stringC E

仅用于编辑,用来把其它编辑变成一段动画。

第一个数值是动画长度,以微秒为单位,第二个数值是动画曲线类型,支持的数值可以通过运行MEL来获取:MGPickerAnimation -q -supportedEasingTypes

-exist(-ex)Q

这个标签只能用于查询模式,用来获取该视图区域是否存在。

-geometry(-g)float float float floatC Q E

用于查询或指定视图区域的位置x, y及宽和高。.

-getIdFromName(-gin)stringQ

只能用于查询。指定一个名字字符窜,将返回所有取这个名字的picker视图区域的id数组。

理论上每个视图区域都应该指定不同的名字,不过这里还是返回数值,以便跟其它命令保持统一。

-list(-ls)Q

只能用于查询来返回这个picker视图里所有的视图区域的ID.

-name(-n)stringC Q E

查询或编辑该视图区域的名字,注意为了保持每个视图区域的名字独特性,实际指定的名字可能跟输入的名字不一样,但会尽量靠近。

-remove(-rm)E

删除该视图区域。

-select(-sel)unsignedintC Q E

在查询下将返回当前picker视图所选择的picker视图区域的id数组。在编辑模式下将选择对应的picker视图区域,配合使用0~3的整数来指定选择模式:

0 = 选择

1 = 加选

2 = 去选

3 = 反选

查询模式下,将返回布尔值表示该视图区域是否当前被选择。

-view(-v)stringC Q E

控制要查询,编辑或创建在哪个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;

C 标签可以在创建模式中使用; E 标签可以在编辑模式中使用
Q 标签可以在查询模式中使用   M 标签可以在一条命令中多次使用。

MEL例子

// Make sure there is an active picker view, 
//run this to create a view region with the specific geometry and name:
string $newViewRegion = `MGPickerViewRegion -name "Body" -geometry 50.0 50.0 300.0 300.0`;

// Activate that view region:
MGPickerViewRegion -e -activate -animation 500 "OutQuad" $newViewRegion;

Python例子

from mgpicker import mgp

# Make sure there is an active picker view, run this to create
# a view region with the specific geometry and name:
newViewRegion = mgp.MGPickerViewRegion(name="Body", geometry=(50.0, 50.0, 300.0, 300.0))

# Activate that view region:
mgp.MGPickerViewRegion(newViewRegion, e=True, activate=True, animation=(500, "OutQuad"))