返回首页 >> Maya文档 >> maya为热键指定 MEL 脚本

为热键指定 MEL 脚本


若要将 MEL 脚本与热键关联,必须先将脚本添加到可用热键命令列表中,然后为创建的命令指定热键。

选择“窗口 > 设置/首选项 > 热键编辑器(Window > Settings/Preferences > Hotkey Editor)”。
命令将分组到类别中。在要将脚本放置在其中的“类别”(Categories)列表中,单击类别名称。
在热键编辑器底部的命令区域,单击“新建”(New)。
键入新命令的“名称”(Name)和“描述”(Description)。
在“命令”(Command)文本框中,键入热键需要运行的 MEL 命令。
单击“接受”(Accept)。
在“键”(Key)文本框中键入键名称,然后启用热键上需要的修饰键。
例如,在文本框中键入 m 并启用 Alt 设置,可以将标记菜单指定给 +m。

在编辑这些设置时,Maya 会显示当前为热键指定的命令(如果有)。请仅在不介意覆盖此命令时指定热键。

设置“方向”(Direction)选项。如果选择“按下”(Press),Maya 将在按下此键时运行命令。如果选择“释放”(Release),Maya 将在是否此键时运行命令。
“按下”(Press)和“释放”之间的区别非常重要,例如在为捕捉模式指定热键时。即:为按下键指定启用捕捉模式的命令,为释放键指定禁用捕捉模式的命令。

单击“指定”(Assign)。
如果设置的热键已经指定了命令,Maya 将询问是否要覆盖此命令。

示例 MEL 脚本

使用以下 MEL 脚本可以创建 X 射线显示和线/着色模式之间的切换。

脚本 1:

/MEL to toggle xray mode on/off
//map to a hotkey
//get the current panel as xray mode works per panel
$currentPanel = `getPanel -withFocus`;
//get the state of xray mode (either on or off)
$state = `modelEditor -q -xray $currentPanel`;
//set it to the opposite state
modelEditor -edit -xray (!$state) $currentPanel;
脚本 2:

//MEL to toggle cameras and image planes on/off
//map to a hotkey
$currentPanel = `getPanel -withFocus`;
$state = `modelEditor -q -cameras $currentPanel`;
modelEditor -edit -cameras (!$state) $currentPanel;
相关主题

为热键指定标记菜单
查看所有已指定热键列表
热键编辑器
请将您关于此页内容的评论发送给我们

(www.cgtsj.com)