对UG菜单脚本进行说明,便于后期进行菜单客制化。
1. NX中功能的组织方式
NX内部一共由三类组织工具的方式,均可由MenuScript语言编辑调整(NX官方定义的脚本语言)。
方法 | 说明 | 示意 |
---|---|---|
主菜单 | menus | ![]() |
右键显示 | shortcut menu | ![]() |
选项卡 | ribbon bar | ![]() |
2. MenuScript主要语法说明
NX的所有功能,都可以视为一个button(按钮)。
MenuScript完成两项工作:
(1)设置按钮的功能和属性
(2)对按钮进行布局(级联菜单、下拉菜单、分组等)
2.1 注意事项
(1)MenuScript的关键字必须全部大写
(2)选项button name和menu name是大小写敏感的
(3)The order of the statement that you use in your custom menu files must follow the order listed in the Menu file format topic.
Menubar Report Tool(菜单栏报告工具)可以报告keyword statements中的错误,而不需要执行所有button.
2.2 Menu文件格式
自定义菜单中可能仅包含其中一部分,但必须按照如下顺序列出。
<menu file format> :=
VERSION <version number>
<menu file mode>
<version number> :=
A positive integer
<menu file mode> :=
<create mode>|<edit mode>
<create mode> :=
CREATE <top menu name>
TITLE <top menu title>
<top menu>
<menu>|<after button>|<before button>|<hide>|<show>| <modify>
<top menu name> :=
UG_GATEWAY_MAIN_MENUBAR|
UG_GATEWAY_VIEW_POPUP
<top menu title> :=
Title of the menu
<edit mode> :=
EDIT <top menu name>
[TITLE <replacement title>] <top menu>|<menu>|<after button>|<modify>|
<before button>|<hide>|<show>
<top menu> :=
TOP_MENU
{ <button> }
END_OF_TOP_MENU
<menu> :=
MENU <cascade button name>
{ <button> }
END_OF_MENU
<modify> :=
MODIFY
{ <button> }
END_OF_MODIFY
<after button> :=
AFTER <button name>
{ <button> }
END_OF_AFTER
<before button> :=
BEFORE <button name>
{ <button> }
END_OF_BEFORE
<hide> :=
HIDE <button name>
<show> :=
SHOW <button name>
<button> :=
<cascade button>|<push button>|<toggle button>|
<application button>|<separator button>
<application button> :=
APPLICATION_BUTTON <button name>
[LABEL <button label>]
[TOOLBAR_LABEL <toolbar button label>]
[RIBBON_LABEL <ribbon button label>]
[NO_REPEAT]
[MESSAGE <message>]
[SYNONYMS <synonym list>]
[HINT <message>]
[BITMAP <bitmap token>]
[POPUP_LABEL <shortcut label token>]
[POPUP_MESSAGE <shortcut message token>]
[ACCELERATOR <accelerator key>]
[SENSITIVITY <sensitivity state> ]
LIBRARIES [[/APPEND|/REPLACE] <library 1> [<library n>]]
[TOP_DIALOG <UI Styler dialog file name>]
MENU_FILES [/APPEND|/REPLACE] <menu file 1> <menu file n>
[VIEW_POPUP_MENU_FILES <menu file name>]
<library> :=
name of the library
<cascade button> :=
CASCADE_BUTTON <cascade button name>
[LABEL <button label>]
[MESSAGE <message>]
<push button> :=
BUTTON <button name>
[LABEL<button label>]
[TOOLBAR_LABEL <toolbar button label>]
[RIBBON_LABEL <ribbon button label>]
[NO_REPEAT]
[MESSAGE <message>]
[SYNONYMS <synonym list>]
[HINT <message>]
[BITMAP <bitmap token>]
[POPUP_LABEL <shortcut label token>]
[POPUP_MESSAGE <shortcut message token>]
[ACCELERATOR <accelerator key>]
[POPUP_LOCATION <location index>]
[SENSITIVITY <sensitivity state>]
ACTIONS [[/PRE|/POST|/REPLACE] {<action>}] [STANDARD] [{<action>}]
<toggle button> :=
TOGGLE_BUTTON <button name>
[LABEL <button label>]
[TOOLBAR_LABEL <toolbar button label>]
[RIBBON_LABEL <ribbon button label>]
[NO_REPEAT]
[MESSAGE <message>]
[SYNONYMS <synonym list>]
[HINT <message>]
[BITMAP <bitmap token>]
[POPUP_LABEL <shortcut label token>]
[POPUP_MESSAGE <shortcut message token>]
[ACCELERATOR <accelerator key>]
[POPUP_LOCATION <location index>]
[VALUE <toggle state> ]
[SENSITIVITY <sensitivity state> ]
ACTIONS [[/PRE|/POST|/REPLACE] {<action>}] [STANDARD] [{<action>}]
<separator button> :=
SEPARATOR
<sensitivity state> :=
ON|OFF
<toggle state> :=
ON|OFF
<action> :=
<NX Open C and C++ program>|
<NX Open C and C++ routine>|
<NX Open UI Styler dialog file name>|
<grip executable>|<system command>
<system command> :=
"<command>"
<NX Open C and C++ program> :=
<callback action> :=
<grip executable> :=
<command> :=
Command name
<button name> :=
Button name
<cascade button name> :=
Cascade button name
<button label> :=
Button label
<message> :=
Message
<synonym list> :=
A comma-separated list of words and phrases
说明
convention | 含义 |
---|---|
< > | Enclose the name of a class of objects. |
:= | Indicates that the description of the class of objects follows to the left of the := |
{ } | Indicates one or more instances of the specified object. |
[ ] | Indicates optional items. Options must appear in the order listed below. |
“竖线” | Separate a list of items from which a choice is to be made. |
2.3 Menu关键字
MenuScript支持两种基础menus:main menu和view shortcut menu
菜单类别 | 关键字 | 案例 |
---|---|---|
main menu | UG_GATEWAY_MAIN_MENUBAR | ug_view_popup.men |
view shortcut menu | UG_GATEWAY_VIEW_POPUP | ug_modeling.men |
如下几个标准菜单文件用于定义主菜单:
ug_main.men
ug_cam.men
ug_drafting.men
ug_modeling.men
2.4 ribbon bar
UG官网参考
在NX界面的基于文件的自定义中,可以使用关键字自定义功能区项目样式及其容器,如组、库、下拉列表等。
2.4.1 group
2.4.2 galleries
2.4.3 drop-down lists
2.4.4 其他关键字
参考资料:
[1] UG官网Menuscript User’s Guide
[2]