Control Active AutoCAD Ribbon Tab from Visual Lisp – RibbonNinja!

1: [LispFunction("RibbonNinja")] 2: public TypedValue GoNinjaGoNinjaGo(ResultBuffer lispArgs) 3: { 4: //check the params 5: Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; 6: if (lispArgs == null) 7: { 8: ed.WriteMessage("\nIncorrect number of arguments. Expected 1 parameter, received none\n"); 9: return new TypedValue((int)LispDataType.Nil); 10: } 11:  12: if(lispArgs.AsArray().Length != 1) 13: { 14: ed.WriteMessage("\nRibbonNinja - Incorrect number of arguments. Expected String - tab keyboard shortcut\n"); 15: return new TypedValue((int)LispDataType.Nil); 16: } 17: //get the tab name 18: String tabKey = Convert.ToString(lispArgs.AsArray()[0].Value); 19:  20: //get the ribbon 21: Autodesk.Windows.RibbonControl ribCntrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl; 22: 23: //find the custom tab using the Id 24: foreach (RibbonTab tab in ribCntrl.Tabs) 25: { 26: //is this the one we're looking for? 27: if(tab.AutomationName.ToUpper() == tabKey.ToUpper()) 28: { 29: //yup - get it active and bail. weeeeee 30: tab.IsActive = true; 31: return new TypedValue((int)LispDataType.T_atom); 32: } 33: } 34: return new TypedValue((int)LispDataType.Nil); 35: }

Thanks for the challenge Shawn!  Here is your shiny new

Page 2 of 3 | Previous page | Next page