若要将 MEL 脚本与热键关联,必须先将脚本添加到可用热键命令列表中,然后为创建的命令指定热键。
“按下”(Press)和“释放”之间的区别非常重要,例如在为捕捉模式指定热键时。即:为按下键指定启用捕捉模式的命令,为释放键指定禁用捕捉模式的命令。
使用以下 MEL 脚本可以创建 X 射线显示和线/着色模式之间的切换。
/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;
//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;