ricaun.Revit.UI
package makes it easier to work with UI and RevitApi, especially with RibbonPanel, RibbonTab, RibbonButton, and RibbonItem in general.
This project was generated by the ricaun.AppLoader Revit plugin, the test project uses the ricaun.RevitTest test framework.
ricaun.Revit.UI
package is designed to work with the plugin AppLoader that allows loading Revit Applications on runtime.
[AppLoader]
public class App : IExternalApplication
{
private RibbonPanel ribbonPanel;
public Result OnStartup(UIControlledApplication application)
{
ribbonPanel = application.CreatePanel("PanelName");
var commandButton = ribbonPanel.CreatePushButton<Commands.Command>()
.SetText("Command")
.SetToolTip("This is a tooltip.")
.SetLongDescription("This is a description.")
.SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico");
if (LanguageExtension.IsBrazilianPortuguese)
{
commandButton.SetText("Comando")
.SetToolTip("Esta Ă© uma dica de ferramenta.")
.SetLongDescription("Esta é uma descrição.");
}
return Result.Succeeded;
}
public Result OnShutdown(UIControlledApplication application)
{
ribbonPanel?.Remove();
return Result.Succeeded;
}
}
RibbonPanelExtension
contains methods related to Autodesk.Windows.RibbonPanel
and Autodesk.Revit.UI.RibbonPanel
UIControlledApplication application;
RibbonPanel ribbonPanel = application.CreatePanel("PanelName");
// application.CreatePanel("TabName", "PanelName");
// application.CreateOrSelectPanel("PanelName");
// application.CreateOrSelectPanel("TabName", "PanelName");
The method GetRibbonItems
allow to select all RibbonItem
concatenated on the RibbonPanel
.
IList<RibbonItem> ribbonItems = ribbonPanel.GetRibbonItems();
The method GetRibbonPanel
allow to select Autodesk.Windows.RibbonPanel
.
Autodesk.Windows.RibbonPanel awRibbonPanel = ribbonPanel.GetRibbonPanel();
The method Remove
allow to remove the RibbonPanel
from Autodesk.Windows
UI.
ribbonPanel.Remove();
RibbonButtonExtension
contains methods related to PushButton
and PushButtonData
PushButton pushButton = ribbonPanel.CreatePushButton<IExternalCommand>();
// ribbonPanel.CreatePushButton<IExternalCommand>("ButtonName");
// ribbonPanel.CreatePushButton<IExternalCommand,IExternalCommandAvailability>();
// ribbonPanel.CreatePushButton<IExternalCommand,IExternalCommandAvailability>("ButtonName");
PushButtonData pushButtonData = ribbonPanel.NewPushButtonData<IExternalCommand>();
// ribbonPanel.NewPushButtonData<IExternalCommand>("ButtonDataName");
// ribbonPanel.NewPushButtonData<IExternalCommand,IExternalCommandAvailability>();
// ribbonPanel.NewPushButtonData<IExternalCommand,IExternalCommandAvailability>("ButtonDataName");
// pushButton.SetAvailability<IExternalCommandAvailability>();
// pushButtonData.SetAvailability<IExternalCommandAvailability>();
RibbonItemExtension
contains methods related to RibbonItem
var ribbonItem = ribbonPanel.CreatePushButton<Commands.Command>();
ribbonItem.SetText("RibbonItemName");
ribbonItem.SetToolTip("ToolTip");
ribbonItem.SetLongDescription("LongDescription");
ribbonItem.SetContextualHelp("ContextualHelpUrl");
ribbonItem.SetItemSize();
ribbonItem.SetShowText();
ribbonItem.SetShowImage();
ribbonItem.SetImage(ImageSource);
ribbonItem.SetLargeImage(ImageSource);
ribbonItem.SetToolTipImage(ImageSource);
or
var ribbonItem = ribbonPanel
.CreatePushButton<Commands.Command>()
.SetText("RibbonItemName")
.SetToolTip("ToolTip")
.SetLongDescription("LongDescription")
.SetContextualHelp("ContextualHelpUrl")
.SetItemSize()
.SetShowText()
.SetShowImage()
.SetImage(ImageSource)
.SetLargeImage(ImageSource)
.SetToolTipImage(ImageSource);
RibbonItemDataExtension
contains methods related to RibbonItemData
var ribbonItemData = ribbonPanel.NewPushButtonData<Commands.Command>();
ribbonItemData.SetText("RibbonItemName");
ribbonItemData.SetToolTip("ToolTip");
ribbonItemData.SetLongDescription("LongDescription");
ribbonItemData.SetContextualHelp("ContextualHelpUrl");
ribbonItemData.SetImage(ImageSource);
ribbonItemData.SetLargeImage(ImageSource);
ribbonItemData.SetToolTipImage(ImageSource);
or
var ribbonItemData = ribbonPanel
.NewPushButtonData<Commands.Command>()
.SetText("RibbonItemName")
.SetToolTip("ToolTip")
.SetLongDescription("LongDescription")
.SetContextualHelp("ContextualHelpUrl")
.SetImage(ImageSource)
.SetLargeImage(ImageSource)
.SetToolTipImage(ImageSource);
RibbonComboBoxExtension
contains methods related to ComboBox
, ComboBoxData
, and ComboBoxMemberData
.
ComboBox comboBox = ribbonPanel.CreateComboBox();
// ribbonPanel.CreateComboBox("ComboBoxName");
// ribbonPanel.CreateComboBox("ComboBoxName", ComboBoxMemberData, ComboBoxMemberData, ...);
comboBox.AddComboBoxMembers(ComboBoxMemberData, ComboBoxMemberData, ...);
comboBox.SetWidth(120);
comboBox.SetCurrent(comboBox.Current);
comboBox.AddCurrentChanged(OnCurrentChanged);
comboBox.RemoveCurrentChanged(OnCurrentChanged);
comboBox.AddDropDownOpened(OnDropDownOpened);
comboBox.RemoveDropDownOpened(OnDropDownOpened);
comboBox.AddDropDownClosed(OnDropDownClosed);
comboBox.RemoveDropDownClosed(OnDropDownClosed);
ComboBoxMember comboBoxMember = comboBox.CreateComboBoxMember();
// comboBox.CreateComboBoxMember("Name");
// comboBox.CreateComboBoxMember("Name", "GroupName");
ComboBoxData comboBoxData = ribbonPanel.NewComboBoxData();
// ribbonPanel.NewComboBoxData("ComboBoxDataName");
ComboBoxMemberData comboBoxMemberData = ribbonPanel.NewComboBoxMemberData();
// ribbonPanel.NewComboBoxMemberData("ComboBoxMemberDataName");
comboBoxMemberData.SetGroupName("GroupName");
PulldownButtonExtension
contains methods related to PulldownButton
PulldownButton pulldownButton = ribbonPanel.CreatePulldownButton();
// ribbonPanel.CreatePulldownButton(PushButtonData, PushButtonData, ...);
// ribbonPanel.CreatePulldownButton("PulldownButtonName");
// ribbonPanel.CreatePulldownButton("PulldownButtonName", PushButtonData, PushButtonData, ...);
pulldownButton.SetListImageSize();
PushButton pushButton = pulldownButton.CreatePushButton<IExternalCommand>();
// pulldownButton.CreatePushButton<IExternalCommand>("ButtonName");
// pulldownButton.CreatePushButton<IExternalCommand,IExternalCommandAvailability>();
// pulldownButton.CreatePushButton<IExternalCommand,IExternalCommandAvailability>("ButtonName");
PushButtonData pushButtonData = pulldownButton.NewPushButtonData<IExternalCommand>();
// pulldownButton.NewPushButtonData<IExternalCommand>("ButtonDataName");
// pulldownButton.NewPushButtonData<IExternalCommand,IExternalCommandAvailability>();
// pulldownButton.NewPushButtonData<IExternalCommand,IExternalCommandAvailability>("ButtonDataName");
pulldownButton.AddPushButtons(PushButtonData, PushButtonData, ...);
RibbonRadioExtension
contains methods related to RadioButtonGroup
, RadioButtonGroupData
, and ToggleButtonData
RadioButtonGroup radioButtonGroup = ribbonPanel.CreateRadioButtonGroup();
// ribbonPanel.CreateRadioButtonGroup("RadioButtonGroupName");
// ribbonPanel.CreateRadioButtonGroup("RadioButtonGroupName", ToggleButtonData, ToggleButtonData, ...);
radioButtonGroup.AddToggleButtons(ToggleButtonData, ToggleButtonData, ...);
RadioButtonGroupData radioButtonGroupData = ribbonPanel.NewRadioButtonGroupData("RadioButtonGroupDataName");
ToggleButtonData ToggleButtonData = ribbonPanel.NewToggleButtonData();
// ribbonPanel.NewToggleButtonData("ToggleButtonDataName");
// ribbonPanel.NewToggleButtonData<IExternalCommand>();
// ribbonPanel.NewToggleButtonData<IExternalCommand>("ToggleButtonDataName");
// ribbonPanel.NewToggleButtonData<IExternalCommand, IExternalCommandAvailability>();
// ribbonPanel.NewToggleButtonData<IExternalCommand, IExternalCommandAvailability>("ToggleButtonDataName");
SplitButtonExtension
contains methods related to SplitButton
SplitButton splitButton = ribbonPanel.CreateSplitButton();
// ribbonPanel.CreateSplitButton(PushButtonData, PushButtonData, ...);
// ribbonPanel.CreateSplitButton("SplitButtonName");
// ribbonPanel.CreateSplitButton("SplitButtonName", PushButtonData, PushButtonData, ...);
PushButton pushButton = splitButton.CreatePushButton<IExternalCommand>();
// splitButton.CreatePushButton<IExternalCommand>("ButtonName");
// splitButton.CreatePushButton<IExternalCommand,IExternalCommandAvailability>();
// splitButton.CreatePushButton<IExternalCommand,IExternalCommandAvailability>("ButtonName");
PushButtonData pushButtonData = splitButton.NewPushButtonData<IExternalCommand>();
// splitButton.NewPushButtonData<IExternalCommand>("ButtonDataName");
// splitButton.NewPushButtonData<IExternalCommand,IExternalCommandAvailability>();
// splitButton.NewPushButtonData<IExternalCommand,IExternalCommandAvailability>("ButtonDataName");
splitButton.AddPushButtons(PushButtonData, PushButtonData, ...);
RibbonTextBoxExtension
contains methods related to TextBox
and TextBoxData
TextBox textBox = ribbonPanel.CreateTextBox();
// ribbonPanel.CreateTextBox("TextBoxName");
textBox.SetValue("Value");
textBox.SetPromptText("PromptText");
textBox.SetShowImageAsButton(true);
textBox.SetSelectTextOnFocus(true);
textBox.SetWidth(120);
textBox.AddEnterPressed(OnEnterPressed);
textBox.RemoveEnterPressed(OnEnterPressed);
TextBoxData textBoxData = ribbonPanel.NewTextBoxData();
// ribbonPanel.NewTextBoxData("TextBoxNameData");
Autodesk.Revit.UI.RibbonItem
--> Autodesk.Windows.RibbonItem
Autodesk.Revit.UI.RibbonItem ribbonItem;
Autodesk.Windows.RibbonItem awRibbonItem = ribbonItem.GetRibbonItem();
Autodesk.Revit.UI.RibbonPanel
--> Autodesk.Windows.RibbonPanel
Autodesk.Revit.UI.RibbonPanel ribbonPanel;
Autodesk.Windows.RibbonPanel awRibbonPanel = ribbonPanel.GetRibbonPanel();
RibbonTabExtension
contains methods related to Autodesk.Windows.RibbonTab
Autodesk.Windows.RibbonTab awRibbonTab = ribbonPanel.GetRibbonTab();
Autodesk.Windows.RibbonTab awRibbonTab = RibbonTabExtension.GetRibbonTab("TabId");
IList<Autodesk.Windows.RibbonTab> awRibbonTabs = RibbonTabExtension.GetRibbonTabs();
The method SetPanelsOrderBy
and SetPanelsOrderByTitle
allow reorder the RibbonPanel
in the RibbonTab
UI.
Autodesk.Windows.RibbonTab awRibbonTab = ribbonPanel.GetRibbonTab();
awRibbonTab.SetPanelsOrderBy(e => e.Source.Title);
awRibbonTab.SetPanelsOrderByTitle();
The method Remove
allow to remove the RibbonTab
from Autodesk.Windows
UI.
awRibbonTab.Remove();
QuickAccessToolBarExtension
contains methods related to add and remove Autodesk.Windows.RibbonItem
to the QuickAccessToolBar.
ribbonItem.AddQuickAccessToolBar();
ribbonItem.RemoveQuickAccessToolBar();
The SetAutodeskOwner()
method applies the window
as an Autodesk owner.
Window window = new MainWindow();
window.SetAutodeskOwner();
The GetBitmapSource()
method transform base64orUriString
or imageAsResourceString
in BitmapSource
.
string base64orUri;
BitmapSource bitmapSource = base64orUri.GetBitmapSource();
string imageAsResourceString;
BitmapSource bitmapSource = imageAsResourceString.GetBitmapSource();
The GetBitmapSource()
method transform Bitmap
, Icon
, Image
in BitmapSource
. The extension is located in the namespace ricaun.Revit.UI.Drawing
.
System.Drawing.Bitmap bitmap;
BitmapSource bitmapSource = bitmap.GetBitmapSource();
System.Drawing.Icon icon;
BitmapSource bitmapSource = icon.GetBitmapSource();
System.Drawing.Image image;
BitmapSource bitmapSource = image.GetBitmapSource();
LanguageExtension
contains methods related to the application language.
LanguageType languageType = LanguageExtension.GetLanguageType();
// LanguageExtension.IsEnglish;
// LanguageExtension.IsFrench;
// LanguageExtension.IsGerman;
// LanguageExtension.IsItalian;
// LanguageExtension.IsJapanese;
// LanguageExtension.IsKorean;
// LanguageExtension.IsPolish;
// LanguageExtension.IsSpanish;
// LanguageExtension.IsChineseSimplified;
// LanguageExtension.IsChineseTraditional;
// LanguageExtension.IsBrazilianPortuguese;
// LanguageExtension.IsRussian;
// LanguageExtension.IsCzech;
Create Autodesk.Windows.RibbonFlowPanel
and Autodesk.Windows.RibbonRowPanel
using Autodesk.Revit.UI.RibbonItem
array.
Autodesk.Revit.UI.RibbonItem[] ribbonItems;
Autodesk.Windows.RibbonFlowPanel awRibbonFlowPanel = ribbonPanel.FlowStackedItems(ribbonItems);
Autodesk.Revit.UI.RibbonItem[] ribbonItems;
Autodesk.Windows.RibbonRowPanel[] awRibbonRowPanels = ribbonPanel.RowStackedItems(ribbonItems);
Autodesk.Revit.UI.RibbonItem[] ribbonItems;
Autodesk.Windows.RibbonRowPanel[] awRibbonRowPanels = ribbonPanel.RowLargeStackedItems(ribbonItems);
Create DialogLauncher
in a Autodesk.Revit.UI.RibbonPanel
using Autodesk.Revit.UI.PushButton
.
Autodesk.Revit.UI.PushButton pushButton;
ribbonPanel.SetDialogLauncher(pushButton);
Autodesk.Windows.RibbonPanel awRibbonPanel;
Autodesk.Windows.RibbonCommandItem ribbonCommandItem = awRibbonPanel.GetDialogLauncher();
Autodesk.Windows.RibbonCommandItem ribbonCommandItem;
Autodesk.Windows.RibbonPanel awRibbonPanel;
awRibbonPanel.SetDialogLauncher(ribbonCommandItem);
This Project is licensed under the MIT License.
Do you like this package? Please star this project on GitHub!