/** * Following method cleanup any housekeeping chores that may be needed. * This method is automatically called by NX. */ public static void UnloadLibrary() { try { if (m_MenuHandler != null) { m_MenuHandler.Dispose(); m_MenuHandler = null; } if (m_Instance != null) { m_Instance = null; } } catch (Exception ex) { //---- Enter your exception handling code here ----- m_UI.NXMessageBox.Show("Menu creator", NXOpen.NXMessageBox.DialogType.Information, ex.Message); } }
/** * Registers the callback methods with the menu handler * */ void RegisterCallbacks() { if (m_MenuHandler != null) { // // Menu handler has already been created and callbacks registered // return; } try { // Initialize the NX Open C++ API environment m_Session = NXOpen.Session.GetSession(); // // Get The NX open UI object // m_UI = NXOpen.UI.GetUI(); // //Create Popup Menu Handler // m_MenuHandler = m_UI.CreateCustomPopupMenuHandler(); // Registration of callback functions // registers the AddPopupMenu Call back m_MenuHandler.RegisterAddCustomPopupMenuCallback(this.AddCustomPopupMenuCallback); // registers the popupMeny Invoked call back m_MenuHandler.RegisterCustomPopupMenuInvokedCallback(this.CustomPopupMenuInvokedCallback); } catch (NXException ex) { m_UI.NXMessageBox.Show("MenuCreator", NXOpen.NXMessageBox.DialogType.Error, ex.Message); throw; } }
/** * Constructor */ private CustomMenuCreator() { m_MenuHandler = null; m_ufSession = NXOpen.UF.UFSession.GetUFSession(); m_ugMgr = m_ufSession.Ugmgr; }