Message 1 of 2
Button in Ribbon is visible but click event isn't triggering

Not applicable
05-13-2014
01:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi I have added a button to a ribbon in Inventor 2014. My button is appearing properly but the problem is that it does nothing when it is clicked.
My code is
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime) { // This method is called by Inventor when it loads the addin. // The AddInSiteObject provides access to the Inventor Application object. // The FirstTime flag indicates if the addin is loaded for the first time. // Initialize AddIn members. m_inventorApplication = addInSiteObject.Application; string clientId = "13c57375-55ee-4c28-a567-7a0d490e5bd3"; RibbonPanel panel; _buttonDef = m_inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition("MergeIDW","MergeIDW",CommandTypesEnum.kQueryOnlyCmdType,clientId,"MergeIDW",null,null,ButtonDisplayEnum.kDisplayTextInLearningMode); string[] ribNames = { "Drawing", "Part", "Assembly", "Presentation", "id_TabAssemble" }; foreach(var ribName in ribNames) { try { panel = m_inventorApplication.UserInterfaceManager.Ribbons[ribName].RibbonTabs["id_TabTools"].RibbonPanels["id_MergeTab"]; } catch { panel = m_inventorApplication.UserInterfaceManager.Ribbons[ribName].RibbonTabs["id_TabTools"].RibbonPanels.Add("MergeIDW", "id_MergeTab", clientId); } panel.CommandControls.AddButton(_buttonDef, true, true, "", false); } _buttonDef.Enabled = true; _buttonDef.OnExecute += _buttonDef_OnExecute; } public void _buttonDef_OnExecute(NameValueMap context) { sample s = new sample(); s.Show(); }
Can someone point out what may be wrong in my code. The problem is happening because I am not able to debug it from Visual Studion because no breakpoints are hit as soon as Inventor starts.