From now on, we will look at how to create various Revit Ribbons using RevitAddinWizard. In this post, we will focus on the PushButton.
The Revit Ribbon Creator can be found from both the menu and the toolbar of the Revit Addin Coder:
After the menu item or the tool is clicked, the Ribbon Creator window will appear:
The first column indicates where to put the ribbon buttons or members; the second column specifies what kind of items to create such as a push button (PushButton) or a separator we are talking about here; the third column is for Text/ItemText/Value input; the fourth is for Tooltip; the fifth Image/LargeImage; and the last Command.
Those data input cells in each row will be available or disabled depending on what ribbon items they are for and confusions or unnecessary input can be avoided. For example, for the second row representing a Separator all remaining cells except for the Image one have been greyed out and disabled. Even for the Image cell it is for display only and cannot be changed.
All cells are available for PushButton input: the Text can be anything meaning; the Tooltip can be anything descriptive; the Image has a default one provided and can be changed to any image through clicking the icon and picking a bitmap from the file open dialog; the Command combo box can be used to choose an external command defined in the current project for the PushButton to call up.
After the OK button is pressed, the following code will be created:
public void AddRibbonItemsToRibbonPanel(RibbonPanel panel)
{
string assemFullName = Assembly.GetExecutingAssembly().Location;
string assemPath = Path.GetDirectoryName(assemFullName);
PushButtonData cnt1Panel_grp0_item1Data = new PushButtonData("cnt1Panel_grp0_item1", @"PushButton1", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton cnt1Panel_grp0_item1 = panel.AddItem(cnt1Panel_grp0_item1Data) as PushButton;
cnt1Panel_grp0_item1.ToolTip = @"A PushButton with the default image.";
cnt1Panel_grp0_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd.bmp");
panel.AddSeparator();
PushButtonData cnt1Panel_grp0_item3Data = new PushButtonData("cnt1Panel_grp0_item3", @"PushButton2", assemFullName, "RevitAddinCSProject.ExtCmd1");
PushButton cnt1Panel_grp0_item3 = panel.AddItem(cnt1Panel_grp0_item3Data) as PushButton;
cnt1Panel_grp0_item3.ToolTip = @"A PushButton with a new image.";
cnt1Panel_grp0_item3.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigA.bmp");
}
public static System.Windows.Media.ImageSource BmpImageSource(string embeddedPath)
{
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedPath);
var decoder = new System.Windows.Media.Imaging.BmpBitmapDecoder(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
return decoder.Frames[0];
}
If some extra code is added to the same External Application:
RibbonPanel panel = _cachedUiCtrApp.CreateRibbonPanel(Guid.NewGuid().ToString());
AddRibbonItemsToRibbonPanel(panel);
panel.Name = "ABC_APP3_PNL2";
panel.Title = "Buttons created by the RevitAddinWizard";
something like the following will be added to the Revit Ribbon (depending on what the specified image really looks like):
All the above mentioned is supported by RevitAddinWizard.
Links to some related articles:
Ribbon of Revit API - PushButton And TextBox
Use Ribbon Creator of RevitAddCoder to Create PushButton And Separator
Use Ribbon Creator of RevitAddCoder to Create TextBox
Ribbon of Revit API - ComboBox And ComboBoxMember
Use Ribbon Creator of RevitAddCoder to Create ComboBox And ComboBoxMember
Ribbon of Revit API - PulldownButton And SplitButton
Use Ribbon Creator of RevitAddCoder to Create PulldownButton And PushButton
Use Ribbon Creator of RevitAddCoder to Create SplitButton And PushButton
Ribbon of Revit API - RadioButtonGroup And ToggleButton
Use Ribbon Creator of RevitAddCoder to Create RadioButtonGroup And ToggleButton
Ribbon of Revit API - Stacked Group And AddStackedItems
Ribbon of Revit API - Stacked Group And PulldownButton
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And PushButton Items
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And TextBox Items
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And PulldownButton Items
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And ComboBox Items
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And Various Items
Ribbon of Revit API - Slideout
Use Ribbon Creator of RevitAddCoder to Create Slideout And Various Buttons
Ribbon of Revit API - Manipulate Panels Created by Other Addins
Access Ribbons Created by Ribbon Creator From Another Addin
Update Ribbons Created by Ribbon Creator From Another Addin
Use Ribbon Creator of RevitAddCoder to Create a Comprehensive Ribbon Panel
Ribbon of Revit API - Title And Name of Panels
Ribbon of Revit API - Text And Name of RibbonItem
Ribbon of Revit API - LongDescription And TooltipImage of RibbonItem
Recent Comments