/*====================================================================*\ FUNCTION : user_initialize() PURPOSE : Pro/DEVELOP standard initialize Define an action and menu button for selecting a component. \*====================================================================*/ ProError SetupCreoSelectPlugin() { log4cpp::Category& logcat = ::log4cpp::Category::getInstance(LOGCAT_LOGFILEONLY); ProError status; uiCmdCmdId cmd_id_select; // Add new button to the menu bar status = ProCmdActionAdd("IsisSelectComponent",(uiCmdCmdActFn)DoSelect, uiProe2ndImmediate, TestAccessAlways, PRO_B_TRUE, PRO_B_TRUE, &cmd_id_select); switch( status = ProCmdDesignate(cmd_id_select, "-ISIS Select Cyphy Component", "-ISIS Select Cyphy Component Label", "-ISIS Select Cyphy Component Description", MSGFIL) ) { case PRO_TK_NO_ERROR: logcat.warnStream() << "The command was designated. Use the Screen Customization dialog box to place it."; break; case PRO_TK_BAD_INPUTS: logcat.warnStream() << "One or more input arguments was invalid."; return PRO_TK_BAD_INPUTS; case PRO_TK_E_NOT_FOUND: logcat.warnStream() << "The message file was not found."; return PRO_TK_E_NOT_FOUND; case PRO_TK_MSG_NOT_FOUND: logcat.warnStream() << "One or more messages was not found in the message file."; return PRO_TK_MSG_NOT_FOUND; } switch( status = ProCmdIconSet(cmd_id_select, "isis_select.png") ) { case PRO_TK_NO_ERROR: logcat.info("The icon was assigned."); break; case PRO_TK_BAD_INPUTS: logcat.warn("The input arguments were invalid."); return PRO_TK_BAD_INPUTS; case PRO_TK_E_NOT_FOUND: logcat.warn("The icon file was not found."); return PRO_TK_E_NOT_FOUND; case PRO_TK_INVALID_FILE: logcat.warn("The file specified was not a Creo Parametric .BIF file or a custom .GIF file."); return PRO_TK_INVALID_FILE; default: logcat.warn("The file specified was not of required format."); return status; } return PRO_TK_NO_ERROR; }
// 添加菜单项 void AddMenuItem(char *menuName, char *itemName, actionFunc menuitemAction, accessFunc menuitemAccess, ProFileName msgFile, char *iconName/* = NULL*/) { string strCmd, strName, strLabel, strHelp, strTip; uiCmdCmdId uiMenuBottonId; strLabel = string(itemName); strCmd = string("cmd") + strLabel; ProError status = ProCmdActionAdd((char*)strCmd.c_str(), (uiCmdCmdActFn)menuitemAction, uiProeImmediate, menuitemAccess, PRO_B_TRUE, PRO_B_TRUE, &uiMenuBottonId); strName = string("Item_") + strLabel + string("Name"); strHelp = strLabel + string(" Operator"); strTip = string("Show ") + strHelp; status = ProMenubarmenuPushbuttonAdd(menuName, (char*)strName.c_str(), (char*)strLabel.c_str(), (char*)strHelp.c_str(), NULL, PRO_B_TRUE, uiMenuBottonId, msgFile); if (iconName != NULL) { status = ProCmdIconSet(uiMenuBottonId, iconName); status = ProCmdDesignate(uiMenuBottonId, (char*)strLabel.c_str(), (char*)strHelp.c_str(), (char*)strTip.c_str(), msgFile); } }
/*====================================================================*\ FUNCTION : user_initialize() PURPOSE : Pro/DEVELOP standard initialize - define menu button \*====================================================================*/ ProError SetupCreoPlugins() { ProError status; uiCmdCmdId cmd_id_update; uiCmdCmdId cmd_id_refresh; uiCmdCmdId cmd_id_add; uiCmdCmdId cmd_id_create; uiCmdCmdId cmd_id_connect; uiCmdCmdId cmd_id_remove; uiCmdCmdId cmd_id_createconn; uiCmdCmdId cmd_id_createanalysispoints; uiCmdCmdId cmd_id_dumpposition; uiCmdCmdId cmd_id_datumresolve; //status = ProUITranslationFilesEnable(); //if (status != PRO_TK_NO_ERROR) return status; /*---------------------------------------------------------------------*\ Add new button to the menu bar \*---------------------------------------------------------------------*/ //ProTKSprintf(revcode, "%s - %s", version, build); // Update (Export) status = ProCmdActionAdd("ISISExportComponent",(uiCmdCmdActFn)DoUpdateComponent,uiProe2ndImmediate, TestAccessAlways, PRO_B_TRUE, PRO_B_TRUE, &cmd_id_update); status = ProCmdDesignate(cmd_id_update, "-ISIS Export Cyphy Component", "-ISIS Export Cyphy Component Label", "-ISIS Export Cyphy Component Description", MSGFIL); ProCmdIconSet(cmd_id_update, "isis_update_component.png"); if (status != PRO_TK_NO_ERROR) return status; // Refresh status = ProCmdActionAdd("ISISRefresh",(uiCmdCmdActFn)DoResync,uiProe2ndImmediate, TestAccessAlways, PRO_B_TRUE, PRO_B_TRUE, &cmd_id_refresh); status = ProCmdDesignate(cmd_id_refresh, "-ISIS Refresh", "-ISIS Refresh Label", "-ISIS Refresh Description", MSGFIL); ProCmdIconSet(cmd_id_refresh, "isis_refresh.png"); if (status != PRO_TK_NO_ERROR) return status; // Add Component status = ProCmdActionAdd("ISISAddComponent", (uiCmdCmdActFn)DoAddComponent, uiProe2ndImmediate, TestAccessAlways, PRO_B_TRUE, PRO_B_TRUE, &cmd_id_add); status = ProCmdDesignate(cmd_id_add, "-ISIS Add Cyphy Component", "-ISIS Add Cyphy Component Label", "-ISIS Add Cyphy Component Description", MSGFIL); ProCmdIconSet(cmd_id_add, "isis_add_component.png"); if (status != PRO_TK_NO_ERROR) return status; // Create Component status = ProCmdActionAdd("ISISCreateComponent", (uiCmdCmdActFn)DoCreateComponent, uiProe2ndImmediate, TestAccessAlways, PRO_B_TRUE, PRO_B_TRUE, &cmd_id_create); status = ProCmdDesignate(cmd_id_create, "-ISIS Create New Component in Cyphy", "-ISIS Create New Component in Cyphy Label", "-ISIS Create New Component in Cyphy Description", MSGFIL); ProCmdIconSet(cmd_id_create, "isis_create_component.png"); if (status != PRO_TK_NO_ERROR) return status; // Connect Components status = ProCmdActionAdd("ISISConnectComponent", (uiCmdCmdActFn)DoConnectComponents, uiProe2ndImmediate, TestAccessAlways, PRO_B_TRUE, PRO_B_TRUE, &cmd_id_connect); status = ProCmdDesignate(cmd_id_connect, "-ISIS Connect Cyphy Component", "-ISIS Connect Cyphy Component Label", "-ISIS Connect Cyphy Component Description", MSGFIL); ProCmdIconSet(cmd_id_connect, "isis_connect.png"); if (status != PRO_TK_NO_ERROR) return status; // Remove Component(s) status = ProCmdActionAdd("ISISRemoveComponent", (uiCmdCmdActFn)DoRemoveComponent, uiProe2ndImmediate, TestAccessAlways, PRO_B_TRUE, PRO_B_TRUE, &cmd_id_remove); status = ProCmdDesignate(cmd_id_remove, "-ISIS Remove Cyphy Component", "-ISIS Remove Cyphy Component Label", "-ISIS Remove Cyphy Component Description", MSGFIL); ProCmdIconSet(cmd_id_remove, "isis_remove_component.png"); if (status != PRO_TK_NO_ERROR) return status; // Create Connector status = ProCmdActionAdd("ISISCreateConnector", (uiCmdCmdActFn)DoCreateConnector, uiProe2ndImmediate, TestAccessAlways, PRO_B_TRUE, PRO_B_TRUE, &cmd_id_createconn); status = ProCmdDesignate(cmd_id_createconn, "-ISIS Create Cyphy Connector", "-ISIS Create Cyphy Connector Label", "-ISIS Create Cyphy Connector Description", MSGFIL); ProCmdIconSet(cmd_id_createconn, "isis_create_connector.png"); if (status != PRO_TK_NO_ERROR) return status; // Create Analysis Points status = ProCmdActionAdd("ISISCreateAnalysisPoints", (uiCmdCmdActFn)DoCreateAnalysisPoints, uiProe2ndImmediate, TestAccessAlways, PRO_B_TRUE, PRO_B_TRUE, &cmd_id_createanalysispoints); status = ProCmdDesignate(cmd_id_createanalysispoints, "-ISIS Create Analysis Point", "-ISIS Create Analysis Point Label", "-ISIS Create Analysis Point Description", MSGFIL); ProCmdIconSet(cmd_id_createanalysispoints, "isis_analysispoint.png"); if (status != PRO_TK_NO_ERROR) return status; // Dump Position Matrices status = ProCmdActionAdd("ISISDumpPosition", (uiCmdCmdActFn)DoDumpPosition, uiProe2ndImmediate, TestAccessAlways, PRO_B_TRUE, PRO_B_TRUE, &cmd_id_dumpposition); status = ProCmdDesignate(cmd_id_dumpposition, "-ISIS Dump Position", "-ISIS Dump Position Label", "-ISIS Dump Position Description", MSGFIL); if (status != PRO_TK_NO_ERROR) return status; // Test datum resolution status = ProCmdActionAdd("ISISDatumResolve", (uiCmdCmdActFn)DoDatumResolve, uiProe2ndImmediate, TestAccessAlways, PRO_B_TRUE, PRO_B_TRUE, &cmd_id_datumresolve); status = ProCmdDesignate(cmd_id_datumresolve, "-ISIS Datum Resolve", "-ISIS Datum Resolve Label", "-ISIS Datum Resolve Description", MSGFIL); if (status != PRO_TK_NO_ERROR) return status; // Load ribbon status = ProRibbonDefinitionfileLoad(L"toolkitribbonui_asm.rbn"); if (status != PRO_TK_NO_ERROR) return status; status = ProRibbonDefinitionfileLoad(L"toolkitribbonui_part.rbn"); if (status != PRO_TK_NO_ERROR) return status; status = ProRibbonDefinitionfileLoad(L"toolkitribbonui_sheetm.rbn"); if (status != PRO_TK_NO_ERROR) return status; /* Upon success */ return PRO_TK_NO_ERROR; }