【发布时间】:2021-08-06 15:08:54
【问题描述】:
我编写了一个 MEL 脚本,在 ScriptEditor 中它工作正常。我想将此 MEL 脚本保存在 .mel 文件中,以用于显示所选几何体的三个平移参数的自定义平视显示器,并且我希望每次加载 Maya 时此 HUD 都出现在视口中。我在 Mac 上运行 Maya。
我该怎么做?
headsUpDisplay -removePosition 0 1;
global proc float[] objectPosition() {
string $selectedNodes[] = `selectedNodes`;
float $position[3];
if (size($selectedNodes) > 0) {
string $mainObject = $selectedNodes[ (size($selectedNodes)-1) ];
$position[0] = `getAttr $mainObject.translateX`;
$position[1] = `getAttr $mainObject.translateY`;
$position[2] = `getAttr $mainObject.translateZ`;
} else {
$position[0] = 0;
$position[1] = 0;
$position[2] = 0;
}
return $position;
}
headsUpDisplay
-section 0
-block 1
-label "Position:"
-command "objectPosition()"
-event "SelectionChanged"
-nodeChanges "attributeChange"
BrandNewHUD;
【问题讨论】: