一、新建MFC Dll工程并配置环境
参考文章
VS2005+ProE3.0参考:ProE二次开发之VS2005+ProE Wildfire 3.0开发环境配置
VS2005+ProE4.0参考:ProE二次开发之VS2005+ProE Wildfire 4.0开发环境配置
二、在工程中添加如下代码
//----------------------------------------------------------------------------- //***************************************************************************** //----------------------------------------------------------------------------- #pragma region #include <ProToolkit.h> #include <ProUtil.h> #include <ProMenuBar.h> #include <ProMenu.h> #include <ProMode.h> #include <ProMdl.h> #include <ProSolid.h> #include <ProAsmcomp.h> #include <ProArray.h> #include <ProModelitem.h> #include <ProLayer.h> // 函数声明 uiCmdAccessState TestAccess(uiCmdAccessMode access_mode); int Test(uiCmdCmdId command, uiCmdValue *p_value, void *p_push_command_data); extern "C" int user_initialize() { ProError err; ProFamilyName MsgFile; ProStringToWstring(MsgFile, "Test_Msg.txt"); // 添加菜单TestMenu err = ProMenubarMenuAdd("TestMenu", "TestMenu", "Help", PRO_B_TRUE, MsgFile); // 添加命令和Menu Item uiCmdCmdId cmd_id1; err = ProCmdActionAdd("Test", Test, uiProeImmediate, TestAccess, PRO_B_FALSE, PRO_B_FALSE, &cmd_id1); err = ProMenubarmenuPushbuttonAdd("TestMenu", "Test", "Test", "Test_Help", NULL, PRO_B_TRUE, cmd_id1, MsgFile); return 0; } extern "C" void user_terminate() { } int Test(uiCmdCmdId command, uiCmdValue *p_value, void *p_push_command_data) { AfxMessageBox(TEXT("Just For Test")); return 0; } uiCmdAccessState TestAccess(uiCmdAccessMode access_mode) { return ACCESS_AVAILABLE; /* ProError err; ProMode mode; err = ProModeCurrentGet(&mode); if (err != PRO_TK_NO_ERROR) { return ACCESS_UNAVAILABLE; } if (mode == PRO_MODE_PART || mode == PRO_MODE_ASSEMBLY) { return ACCESS_AVAILABLE; } else { return ACCESS_UNAVAILABLE; } */ } #pragma endregion //----------------------------------------------------------------------------- //***************************************************************************** //-----------------------------------------------------------------------------
三、示例源码
VS2005+ProE3.0
下载地址:http://download.csdn.net/detail/wangyao1052/4916817
解压缩
运行Test\Bin\GoProE.bat
将启动ProE并加载菜单,单击菜单项弹出示例MessageBox.
注意:记着将GoProE.bat中Call后的路径改为你本机上的ProE的安装路径。