NX9+VS2012
1.打开D:Program FilesSiemensNX 9.0UGIImenusug_main.men
找到装配和PMI,在中间加上一段
TOGGLE_BUTTON LSYTOOLS LABEL 自定义工具箱 BITMAP cam_new_tool ACTIONS LSYTOOLS
2.打开D:Program FilesSiemensNX 9.0UGIImenusprofilesAll bn_application.rtb
找到建模,在前面加上一段
1 BUTTON LSYTOOLS
在D:Program FilesSiemensNX 9.0里新建一个文件夹LSYTOOLS
在LSYTOOLS创建两个文件夹Application和Startup
在Startup里创建菜单文件LSYTOOLS.men
写入内容如下
1 VERSION 120 2 EDIT UG_GATEWAY_MAIN_MENUBAR 3 4 AFTER UG_HELP 5 CASCADE_BUTTON LSYTools 6 LABEL 自定义工具箱 7 END_OF_AFTER 8 9 MENU LSYTools 10 11 BUTTON LSYDrawTools 12 LABEL 图纸工具 13 BITMAP border_zones 14 ACTIONS LSYDrawTools 15 16 BUTTON LSYStlPdfTools 17 LABEL 导出STL PDF工具 18 BITMAP true_shade 19 ACTIONS LSYStlPdfTools 20 21 BUTTON LSYExcelTools 22 LABEL 导入EXCEL创建曲线 23 BITMAP spreadsheet 24 ACTIONS Test1 25 26 BUTTON LSYUpdateDrawViewTools 27 LABEL 切换到工程图工具 28 BITMAP appl_drafting 29 ACTIONS Update_Draw_View 30 31 BUTTON LSYWrite_Dim_NameTools 32 LABEL 工程图改尺寸名字工具 33 BITMAP edit_text 34 ACTIONS Write_Dim_Name 35 36 BUTTON OpenWenJianJia 37 LABEL 打开当前part文件夹 38 BITMAP fileopen 39 ACTIONS OpenWenJianJia 40 41 BUTTON CycleSetExp 42 LABEL 批量修改表达式 43 BITMAP equals 44 ACTIONS CycleSetExp 45 46 BUTTON OpenTxtWriteExp 47 LABEL 记事本编辑if/else表达式 48 BITMAP rename 49 ACTIONS OpenTxtWriteExp 50 51 BUTTON CreateExpGroup 52 LABEL 创建表达式组 53 BITMAP styler_group_box 54 ACTIONS CreateExpGroup 55 56 BUTTON CreateFeatureGroup 57 LABEL 创建特征组 58 BITMAP folder_new 59 ACTIONS CreateFeatureGroup 60 61 BUTTON CycleDeleteTuKuang 62 LABEL 批量删除图框 63 BITMAP delete 64 ACTIONS CycleDeleteTuKuang 65 66 BUTTON CreateHelp 67 LABEL 自定义1 68 BITMAP styler_string 69 ACTIONS CreateHelp 70 71 BUTTON CreateHelpRedBlock 72 LABEL 自定义2 73 BITMAP curve_section 74 ACTIONS CreateHelpRedBlock 75 76 77 END_OF_MENU
在Application里创建LSYTOOLS.rtb功能区工具栏,写入内容如下。
1 TITLE 自定义工具箱 2 VERSION 170 3 4 BEGIN_GROUP 图纸工具 5 BUTTON LSYDrawTools 6 BUTTON LSYUpdateDrawViewTools 7 RIBBON_STYLE MEDIUM_IMAGE_AND_TEXT 8 BUTTON LSYWrite_Dim_NameTools 9 RIBBON_STYLE MEDIUM_IMAGE_AND_TEXT 10 BUTTON CycleDeleteTuKuang 11 RIBBON_STYLE MEDIUM_IMAGE_AND_TEXT 12 END_GROUP 13 14 15 BEGIN_GROUP 表达式工具 16 BUTTON CycleSetExp 17 BUTTON CreateExpGroup 18 RIBBON_STYLE MEDIUM_IMAGE_AND_TEXT 19 BUTTON OpenTxtWriteExp 20 RIBBON_STYLE MEDIUM_IMAGE_AND_TEXT 21 END_GROUP 22 23 BEGIN_GROUP 帮助图工具 24 BUTTON CreateHelp 25 BUTTON CreateHelpRedBlock 26 END_GROUP 27 28 BEGIN_GROUP 建模工具 29 BUTTON OpenWenJianJia 30 BUTTON CreateFeatureGroup 31 RIBBON_STYLE MEDIUM_IMAGE_AND_TEXT 32 BUTTON LSYStlPdfTools 33 RIBBON_STYLE MEDIUM_IMAGE_AND_TEXT 34 BUTTON LSYExcelTools 35 RIBBON_STYLE MEDIUM_IMAGE_AND_TEXT 36 END_GROUP
在创建LSYTOOLS.tbr经典工具栏,写入内容如下。
1 TITLE 自定义工具箱 2 VERSION 170 3 BUTTON LSYDrawTools 4 BUTTON LSYStlPdfTools 5 BUTTON LSYExcelTools 6 BUTTON LSYUpdateDrawViewTools 7 BUTTON LSYWrite_Dim_NameTools 8 BUTTON OpenWenJianJia 9 BUTTON CycleSetExp 10 BUTTON OpenTxtWriteExp 11 BUTTON CreateExpGroup 12 BUTTON CreateFeatureGroup 13 BUTTON CycleDeleteTuKuang 14 BUTTON CreateHelp
设置环境变量
把D:Program FilesSiemensNX 9.0LSYTOOLS,路径复制到D:Program FilesSiemensNX 9.0UGIImenuscustom_dirs.dat里,
打开粘贴到最后一行
下面去VS里写代码
1 #include <uf.h> 2 #include <uf_ui.h> 3 #include <uf_mb.h> 4 5 6 UF_initialize(); 7 8 static UF_UI_toolbar_id_t DEMP_tbr_id = NULL; 9 static UF_UI_ribbon_id_t ribbon_id = NULL; 10 11 int demoToggleBtn_id; 12 UF_MB_state_t demo_btn_state; 13 UF_MB_ask_button_id("LSYTOOLS", &demoToggleBtn_id);//获取按钮的ID 14 UF_MB_ask_toggle_state(demoToggleBtn_id, &demo_btn_state);//获取切换按钮的当前状态 15 if (UF_MB_ON == demo_btn_state) 16 { 17 if (DEMP_tbr_id == NULL) 18 { 19 UF_UI_create_toolbar("LSYTOOLS.tbr", 1, &DEMP_tbr_id);//创建经典工具栏 20 UF_UI_set_toolbar_vis(DEMP_tbr_id, 1);//设置经典工具栏的可见性 21 22 UF_UI_create_ribbon("LSYTOOLS.rtb", 1, &ribbon_id);//创建功能区工具栏 23 UF_UI_set_ribbon_vis(ribbon_id, 1);//设置功能区工具栏的可见性 24 25 } 26 } 27 else 28 { 29 UF_UI_remove_toolbar(DEMP_tbr_id);//删除经典工具栏 30 UF_UI_remove_ribbon(ribbon_id);//删除功能区工具栏 31 DEMP_tbr_id = NULL; 32 ribbon_id = NULL; 33 } 34 35 36 UF_terminate(); 37 38 Caesar卢尚宇 39 2019年7月15日
把编译出来的DLL放到D:Program FilesSiemensNX 9.0LSYTOOLSApplication里,名字改为LSYTOOLS.dll
打开UG