public void Execute(object parameter) { RibbonCommandItem cmd = parameter as RibbonCommandItem; Document dwg = Application.DocumentManager.MdiActiveDocument; dwg.SendStringToExecute((string)cmd.CommandParameter, true, false, false); }
public void Execute(object parameter) { RibbonCommandItem IfcExportButton = new RibbonCommandItem(); if (IfcExportButton != null) { //execute an AutoCAD command, or your custom command defined by [CommandMethod] Document dwg = Application.DocumentManager.MdiActiveDocument; dwg.SendStringToExecute((string)IfcExportButton.CommandParameter + "IFCEXPORTALL" + " ", true, false, true); } }
public void Execute(object parameter) { RibbonCommandItem ChangeConfigFileButton = new RibbonCommandItem(); if (ChangeConfigFileButton != null) { //execute an AutoCAD command, or your custom command defined by [CommandMethod] Document dwg = Application.DocumentManager.MdiActiveDocument; dwg.SendStringToExecute((string)ChangeConfigFileButton.CommandParameter + "SelectConfigFile" + " ", true, false, true); } }
public void Execute(object parameter) { RibbonCommandItem MoveRevLineBtn = new RibbonCommandItem(); if (MoveRevLineBtn != null) { //execute an AutoCAD command, or your custom command defined by [CommandMethod] Document dwg = Application.DocumentManager.MdiActiveDocument; dwg.SendStringToExecute((string)MoveRevLineBtn.CommandParameter + "MoveRevLineBtn" + " ", true, false, true); } }
public void Execute(object parameter) { //TODO: Add authentication check here RibbonCommandItem cmd = parameter as RibbonCommandItem; Document dwg = Application.DocumentManager.MdiActiveDocument; if (cmd != null) { dwg.SendStringToExecute((string)cmd.CommandParameter, true, false, false); } }
public void Execute(object parameter) { Document doc = Application.DocumentManager.MdiActiveDocument; if (parameter is RibbonButton) { RibbonButton button = parameter as RibbonButton; RibbonCommandItem cmd = parameter as RibbonCommandItem; doc.SendStringToExecute((string)cmd.CommandParameter, true, false, true); doc.Editor.WriteMessage("\nRibbonButton Executed: " + button.Text + "\n"); } }
public static bool SetShortCut(this RibbonCommandItem commandItem, string key) { try { if (commandItem == null || string.IsNullOrEmpty(key)) { return(false); } RibbonTab parentTab; RibbonPanel parentPanel; var commandId = ControlHelper.GetCommandId(commandItem); if (string.IsNullOrEmpty(commandId)) { commandId = Guid.NewGuid().ToString(); ControlHelper.SetCommandId(commandItem, commandId); } ComponentManager.Ribbon.FindItem(commandItem.Id, false, out parentPanel, out parentTab, true); if (parentTab == null || parentPanel == null) { return(false); } var path = $"{parentTab.Id}>{parentPanel.Source.Id}"; var shortcutItem = new ShortcutItem(commandItem.Text, commandId, key, path) { ShortcutType = StType.RevitAPI }; KeyboardShortcutService.applyShortcutChanges( new Dictionary <string, ShortcutItem> { { commandId, shortcutItem } }); return(true); } catch (Exception) { return(false); } }
/// <summary> /// 给指定按钮设置快捷键 /// </summary> /// <param name="commandItem"></param> /// <param name="key"></param> /// <returns></returns> public static bool SetShortCut(this RibbonCommandItem commandItem, string key) { try { if (commandItem == null || string.IsNullOrEmpty(key)) { return(false); } var parentTab = default(Autodesk.Windows.RibbonTab); var parentPanel = default(Autodesk.Windows.RibbonPanel); Autodesk.Windows.ComponentManager.Ribbon.FindItem(commandItem.Id, false, out parentPanel, out parentTab, true); if (parentTab == null || parentPanel == null) { return(false); } var path = string.Format("{0}>{1}", parentTab.Id, parentPanel.Source.Id); var commandId = ControlHelper.GetCommandId(commandItem); if (string.IsNullOrEmpty(commandId)) { commandId = Guid.NewGuid().ToString(); ControlHelper.SetCommandId(commandItem, commandId); } var shortcutItem = new ShortcutItem(commandItem.Text, commandId, key, path); shortcutItem.ShortcutType = StType.RevitAPI; KeyboardShortcutService.applyShortcutChanges( new Dictionary <string, ShortcutItem>() { { commandId, shortcutItem } } ); return(true); } catch (Exception) { return(false); } }
public static void AddItem(this RibbonItemCollection items, RibbonCommandItem item, string text, ICommand command, Bitmap smallImage, Bitmap largeImage) { item.Text = text; item.ShowText = true; item.ShowImage = false; if ((smallImage != null) || (largeImage != null)) { item.ShowImage = true; if (largeImage == null) { largeImage = smallImage; } item.Image = GetImage(smallImage); item.LargeImage = GetImage(largeImage); } item.Size = RibbonItemSize.Standard; item.CommandHandler = command; items.Add(item); }
public void Execute(object parameter) { RibbonCommandItem rci = parameter as RibbonCommandItem; (rci.CommandParameter as AppUI).ShowDialog(); }
public void Execute(object parameter) { RibbonCommandItem btn = new RibbonCommandItem(); if (btn != null) { //execute an AutoCAD command, or your custom commandd defined by [CommandMethod] Document dwg = Application.DocumentManager.MdiActiveDocument; dwg.SendStringToExecute((string)btn.CommandParameter + "PlotThisPage" + " ", true, false, true); } }
public static void AddItem(this RibbonItemCollection items, RibbonCommandItem item, AcCommand command) { item.Description = command.Description; AddItem(items, item, command.DisplayName, command, command.SmallImage, command.LargeImage); }