I've followed a few examples and am able to create a new tab on the Ribbon, with panels and buttons, that appears when my DLL is loaded. However, it doesn't persist through workspace changes. I've read that this is due to my use of AdWindows.dll and my current code, as opposed to AcCui.dll, which would modify a CUIx file (that I don't know much about) to make persistant changes.
Does anyone know of examples of this? I've searched around and haven't seen them.
Here is a sample of my current code.
public class Commands : Autodesk.AutoCAD.Runtime.IExtensionApplication { public void Initialize() { Application.Idle += callback_Idle; } private void callback_Idle(Object sender, EventArgs e) { CreateRibbon(); Application.Idle -= callback_Idle; } private void CreateRibbon() { RibbonControl mainAcadRibbon = ComponentManager.Ribbon; if (mainAcadRibbon != null) { RibbonTab rTab = mainAcadRibbon.FindTab("Tab Name"); if (rTab != null) { mainAcadRibbon.Tabs.Remove(rTab); } rTab = new RibbonTab(); rTab.Title = "Title"; rTab.Id = "ID"; mainAcadRibbon.Tabs.Add(rTab); addPanelsToRibbon(rTab); } } static void addPanelsToRibbon(RibbonTab rtab) { rtab.Panels.Add(panelExample()); } static RibbonPanel panelExample() { RibbonButton rb1; RibbonButton rb2; RibbonPanelSource rps = new RibbonPanelSource(); rps.Title = "Title"; RibbonPanel rp = new RibbonPanel(); rp.Source = rps; rb1 = new RibbonButton(); rb1.Name = "Name1"; rb1.ShowText = true; rb1.Text = "Text1"; rb1.CommandHandler = new RibbonCommandHandler(); rps.Items.Add(rb1); rb2 = new RibbonButton(); rb2.Name = "Name2"; rb2.ShowText = true; rb2.Text = "Text2"; rb2.CommandHandler = new RibbonCommandHandler(); rps.Items.Add(rb2); return rp; } public class RibbonCommandHandler : System.Windows.Input.ICommand { public bool CanExecute(object parameter) { return true; } // CanExecuteChanged must be implemented, even if not used. public event EventHandler CanExecuteChanged; public void Execute(object parameter) { Document doc = Application.DocumentManager.MdiActiveDocument; if (parameter is RibbonButton) { try { switch (button.Name.ToString()) { case "Name1": break; case "Name2": break; default: break; } } catch (Autodesk.AutoCAD.Runtime.Exception ex) { Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.ToString()); } catch (System.NullReferenceException ex) { Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.ToString()); } } } } }