Let’s see how to create a comprehensive ribbon panel (RibbonPanel) which holds all kinds of ribbon items such as PushButton, TextBox, ComboBox, ComboBoxMember, PulldownButton, SplitButton, RadioButtonGroup, ToggleButton, Stacked Groups, SlideOut, and Separator using RevitAddinWizard.
For example, how to create ribbons like the following?
Though there are a lot of ribbon items in the example and they cover almost all kinds of combinations that the Revit API can provide, the UI and the steps are pretty the same. The Ribbon Creator tool can do all of these. After the tool of the Revit Addin Coder is clicked, the Ribbon Creator window will appear. Then we can specify these ribbon groups or members one by one the same way as we did many times before:
Besides providing data input for the various ribbon items please also give the Ribbon Creator method a name and choose by which external application (IExternalApplication) the ribbon is going to be handled.
After the OK button is pressed, some comprehensive code like the following 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.ExtCmd1");
PushButton cnt1Panel_grp0_item1 = panel.AddItem(cnt1Panel_grp0_item1Data) as PushButton;
cnt1Panel_grp0_item1.ToolTip = @"PushButton 1 in Panel";
cnt1Panel_grp0_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigA.bmp");
PushButtonData cnt1Panel_grp0_item2Data = new PushButtonData("cnt1Panel_grp0_item2", @"PushButton2", assemFullName, "RevitAddinCSProject.ExtCmd2");
PushButton cnt1Panel_grp0_item2 = panel.AddItem(cnt1Panel_grp0_item2Data) as PushButton;
cnt1Panel_grp0_item2.ToolTip = @"PushButton 2 in Panel";
cnt1Panel_grp0_item2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigB.bmp");
panel.AddSeparator();
RadioButtonGroupData cnt2Panel_grp1Data = new RadioButtonGroupData("cnt2Panel_grp1");
RadioButtonGroup cnt2Panel_grp1 = panel.AddItem(cnt2Panel_grp1Data) as RadioButtonGroup;
ToggleButtonData cnt2Panel_grp1_item1Data = new ToggleButtonData("cnt2Panel_grp1_item1", @"ToggleButton1", assemFullName, "RevitAddinCSProject.ExtCmd3");
ToggleButton cnt2Panel_grp1_item1 = cnt2Panel_grp1.AddItem(cnt2Panel_grp1_item1Data);
cnt2Panel_grp1_item1.ToolTip = @"ToggleButton 1 in RadioButtonGroup";
cnt2Panel_grp1_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigC.bmp");
ToggleButtonData cnt2Panel_grp1_item2Data = new ToggleButtonData("cnt2Panel_grp1_item2", @"ToggleButton2", assemFullName, "RevitAddinCSProject.ExtCmd4");
ToggleButton cnt2Panel_grp1_item2 = cnt2Panel_grp1.AddItem(cnt2Panel_grp1_item2Data);
cnt2Panel_grp1_item2.ToolTip = @"ToggleButton 2 in RadioButtonGroup";
cnt2Panel_grp1_item2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigD.bmp");
SplitButtonData cnt3Panel_grp1Data = new SplitButtonData("cnt3Panel_grp1", Guid.NewGuid().ToString() );
SplitButton cnt3Panel_grp1 = panel.AddItem(cnt3Panel_grp1Data) as SplitButton;
PushButtonData cnt3Panel_grp1_item1Data = new PushButtonData("cnt3Panel_grp1_item1", @"PushButton3", assemFullName, "RevitAddinCSProject.ExtCmd1");
PushButton cnt3Panel_grp1_item1 = cnt3Panel_grp1.AddPushButton(cnt3Panel_grp1_item1Data) as PushButton;
cnt3Panel_grp1_item1.ToolTip = @"PushButton 3 in SplitButton";
cnt3Panel_grp1_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigA.bmp");
PushButtonData cnt3Panel_grp1_item2Data = new PushButtonData("cnt3Panel_grp1_item2", @"PushButton4", assemFullName, "RevitAddinCSProject.ExtCmd2");
PushButton cnt3Panel_grp1_item2 = cnt3Panel_grp1.AddPushButton(cnt3Panel_grp1_item2Data) as PushButton;
cnt3Panel_grp1_item2.ToolTip = @"PushButton 4 in SplitButton";
cnt3Panel_grp1_item2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigB.bmp");
panel.AddSeparator();
PushButtonData cnt5Stacked_grp0_item1Data = new PushButtonData("cnt5Stacked_grp0_item1", @"PushButton5", assemFullName, "RevitAddinCSProject.ExtCmd3");
PushButtonData cnt5Stacked_grp0_item2Data = new PushButtonData("cnt5Stacked_grp0_item2", @"PushButton6", assemFullName, "RevitAddinCSProject.ExtCmd4");
PulldownButtonData cnt5Stacked_grp1Data = new PulldownButtonData("cnt5Stacked_grp1", @"PulldownButton1");
IList<RibbonItem> cnt5Stacked = panel.AddStackedItems(cnt5Stacked_grp0_item1Data, cnt5Stacked_grp0_item2Data, cnt5Stacked_grp1Data);
PushButton cnt5Stacked_grp0_item1 = cnt5Stacked[0] as PushButton;
cnt5Stacked_grp0_item1.ToolTip = @"PushButton 5 in Stacked 1";
cnt5Stacked_grp0_item1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smalla.bmp");
PushButton cnt5Stacked_grp0_item2 = cnt5Stacked[1] as PushButton;
cnt5Stacked_grp0_item2.ToolTip = @"PushButton 6 in Stacked 1";
cnt5Stacked_grp0_item2.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smallb.bmp");
PulldownButton cnt5Stacked_grp1 = cnt5Stacked[2] as PulldownButton;
cnt5Stacked_grp1.ToolTip = @"PulldownButton 1 in Stacked 1";
cnt5Stacked_grp1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.groupsmall.bmp");
PushButtonData cnt5Stacked_grp1_item1Data = new PushButtonData("cnt5Stacked_grp1_item1", @"PushButton7", assemFullName, "RevitAddinCSProject.ExtCmd1");
PushButton cnt5Stacked_grp1_item1 = cnt5Stacked_grp1.AddPushButton(cnt5Stacked_grp1_item1Data) as PushButton;
cnt5Stacked_grp1_item1.ToolTip = @"PushButton 7 in Stacked PulldownButton 1";
cnt5Stacked_grp1_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.smallc.bmp");
PushButtonData cnt5Stacked_grp1_item2Data = new PushButtonData("cnt5Stacked_grp1_item2", @"PushButton8", assemFullName, "RevitAddinCSProject.ExtCmd2");
PushButton cnt5Stacked_grp1_item2 = cnt5Stacked_grp1.AddPushButton(cnt5Stacked_grp1_item2Data) as PushButton;
cnt5Stacked_grp1_item2.ToolTip = @"PushButton 8 in Stacked PulldownButton 1";
cnt5Stacked_grp1_item2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.smalld.bmp");
panel.AddSeparator();
panel.AddSeparator();
TextBoxData cnt7Stacked_grp0_item1Data = new TextBoxData("cnt7Stacked_grp0_item1");
TextBoxData cnt7Stacked_grp0_item2Data = new TextBoxData("cnt7Stacked_grp0_item2");
ComboBoxData cnt7Stacked_grp1Data = new ComboBoxData("cnt7Stacked_grp1");
IList<RibbonItem> cnt7Stacked = panel.AddStackedItems(cnt7Stacked_grp0_item1Data, cnt7Stacked_grp0_item2Data, cnt7Stacked_grp1Data);
Autodesk.Revit.UI.TextBox cnt7Stacked_grp0_item1 = cnt7Stacked[0] as Autodesk.Revit.UI.TextBox;
cnt7Stacked_grp0_item1.ToolTip = @"TextBox 1 in Stacked 2";
cnt7Stacked_grp0_item1.Value = @"TextBox1";
cnt7Stacked_grp0_item1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.CheckAndUpdate.bmp");
cnt7Stacked_grp0_item1.ShowImageAsButton = true;
cnt7Stacked_grp0_item1.EnterPressed += CallbackOfTextBoxEnterPressed;
Autodesk.Revit.UI.TextBox cnt7Stacked_grp0_item2 = cnt7Stacked[1] as Autodesk.Revit.UI.TextBox;
cnt7Stacked_grp0_item2.ToolTip = @"TextBox 2 in Stacked 2";
cnt7Stacked_grp0_item2.Value = @"TextBox2";
cnt7Stacked_grp0_item2.Image = BmpImageSource(@"RevitAddinCSProject.Resources.CheckAndUpdate.bmp");
cnt7Stacked_grp0_item2.ShowImageAsButton = true;
cnt7Stacked_grp0_item2.EnterPressed += CallbackOfTextBoxEnterPressed;
Autodesk.Revit.UI.ComboBox cnt7Stacked_grp1 = cnt7Stacked[2] as Autodesk.Revit.UI.ComboBox;
cnt7Stacked_grp1.ItemText = @"ComboBox1";
cnt7Stacked_grp1.ToolTip = @"ComboBox 1 in Stacked 2";
ComboBoxMemberData cnt7Stacked_grp1_item1Data = new ComboBoxMemberData("cnt7Stacked_grp1_item1", @"ComboBoxMember1");
ComboBoxMember cnt7Stacked_grp1_item1 = cnt7Stacked_grp1.AddItem(cnt7Stacked_grp1_item1Data);
cnt7Stacked_grp1_item1.ToolTip = @"ComboBoxMember 1 in Stacked ComboBox 1";
cnt7Stacked_grp1_item1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smalla.bmp");
ComboBoxMemberData cnt7Stacked_grp1_item2Data = new ComboBoxMemberData("cnt7Stacked_grp1_item2", @"ComboBoxMember2");
ComboBoxMember cnt7Stacked_grp1_item2 = cnt7Stacked_grp1.AddItem(cnt7Stacked_grp1_item2Data);
cnt7Stacked_grp1_item2.ToolTip = @"ComboBoxMember 2 in Stacked ComboBox 1";
cnt7Stacked_grp1_item2.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smallb.bmp");
ComboBoxMemberData cnt7Stacked_grp1_item3Data = new ComboBoxMemberData("cnt7Stacked_grp1_item3", @"ComboBoxMember3");
ComboBoxMember cnt7Stacked_grp1_item3 = cnt7Stacked_grp1.AddItem(cnt7Stacked_grp1_item3Data);
cnt7Stacked_grp1_item3.ToolTip = @"ComboBoxMember 3 in Stacked ComboBox 1";
cnt7Stacked_grp1_item3.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smallc.bmp");
panel.AddSlideOut();
PushButtonData SlideOut_cnt8Panel_grp1_item1Data = new PushButtonData("SlideOut_cnt8Panel_grp1_item1", @"PushButton9", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton SlideOut_cnt8Panel_grp1_item1 = panel.AddItem(SlideOut_cnt8Panel_grp1_item1Data) as PushButton;
SlideOut_cnt8Panel_grp1_item1.ToolTip = @"PushButton 9 in SlideOut";
SlideOut_cnt8Panel_grp1_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigA.bmp");
PushButtonData SlideOut_cnt8Panel_grp1_item2Data = new PushButtonData("SlideOut_cnt8Panel_grp1_item2", @"PushButton10", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton SlideOut_cnt8Panel_grp1_item2 = panel.AddItem(SlideOut_cnt8Panel_grp1_item2Data) as PushButton;
SlideOut_cnt8Panel_grp1_item2.ToolTip = @"PushButton 10 in SlideOut";
SlideOut_cnt8Panel_grp1_item2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigB.bmp");
PushButtonData SlideOut_cnt8Panel_grp1_item3Data = new PushButtonData("SlideOut_cnt8Panel_grp1_item3", @"PushButton11", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton SlideOut_cnt8Panel_grp1_item3 = panel.AddItem(SlideOut_cnt8Panel_grp1_item3Data) as PushButton;
SlideOut_cnt8Panel_grp1_item3.ToolTip = @"PushButton 11 in SlideOut";
SlideOut_cnt8Panel_grp1_item3.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigC.bmp");
panel.AddSeparator();
PulldownButtonData SlideOut_cnt8Panel_grp2Data = new PulldownButtonData("SlideOut_cnt8Panel_grp2", @"PulldownButton2");
PulldownButton SlideOut_cnt8Panel_grp2 = panel.AddItem(SlideOut_cnt8Panel_grp2Data) as PulldownButton;
SlideOut_cnt8Panel_grp2.ToolTip = @"PulldownButton 2 in SlideOut";
SlideOut_cnt8Panel_grp2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd.bmp");
PushButtonData SlideOut_cnt8Panel_grp2_item1Data = new PushButtonData("SlideOut_cnt8Panel_grp2_item1", @"PushButton12", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton SlideOut_cnt8Panel_grp2_item1 = SlideOut_cnt8Panel_grp2.AddPushButton(SlideOut_cnt8Panel_grp2_item1Data) as PushButton;
SlideOut_cnt8Panel_grp2_item1.ToolTip = @"PushButton 12 in PulldownButton 2 of SlideOut";
SlideOut_cnt8Panel_grp2_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigA.bmp");
PushButtonData SlideOut_cnt8Panel_grp2_item2Data = new PushButtonData("SlideOut_cnt8Panel_grp2_item2", @"PushButton13", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton SlideOut_cnt8Panel_grp2_item2 = SlideOut_cnt8Panel_grp2.AddPushButton(SlideOut_cnt8Panel_grp2_item2Data) as PushButton;
SlideOut_cnt8Panel_grp2_item2.ToolTip = @"PushButton 13 in PulldownButton 2 of SlideOut";
SlideOut_cnt8Panel_grp2_item2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigB.bmp");
panel.AddSeparator();
SplitButtonData SlideOut_cnt9Panel_grp1Data = new SplitButtonData("SlideOut_cnt9Panel_grp1", Guid.NewGuid().ToString() );
SplitButton SlideOut_cnt9Panel_grp1 = panel.AddItem(SlideOut_cnt9Panel_grp1Data) as SplitButton;
PushButtonData SlideOut_cnt9Panel_grp1_item1Data = new PushButtonData("SlideOut_cnt9Panel_grp1_item1", @"PushButton14", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton SlideOut_cnt9Panel_grp1_item1 = SlideOut_cnt9Panel_grp1.AddPushButton(SlideOut_cnt9Panel_grp1_item1Data) as PushButton;
SlideOut_cnt9Panel_grp1_item1.ToolTip = @"PushButton 14 in SlideOut";
SlideOut_cnt9Panel_grp1_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigA.bmp");
PushButtonData SlideOut_cnt9Panel_grp1_item2Data = new PushButtonData("SlideOut_cnt9Panel_grp1_item2", @"PushButton15", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton SlideOut_cnt9Panel_grp1_item2 = SlideOut_cnt9Panel_grp1.AddPushButton(SlideOut_cnt9Panel_grp1_item2Data) as PushButton;
SlideOut_cnt9Panel_grp1_item2.ToolTip = @"PushButton 15 in SlideOut";
SlideOut_cnt9Panel_grp1_item2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigB.bmp");
PushButtonData SlideOut_cnt9Panel_grp1_item3Data = new PushButtonData("SlideOut_cnt9Panel_grp1_item3", @"PushButton16", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton SlideOut_cnt9Panel_grp1_item3 = SlideOut_cnt9Panel_grp1.AddPushButton(SlideOut_cnt9Panel_grp1_item3Data) as PushButton;
SlideOut_cnt9Panel_grp1_item3.ToolTip = @"PushButton 16 in SlideOut";
SlideOut_cnt9Panel_grp1_item3.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigC.bmp");
panel.AddSeparator();
panel.AddSeparator();
PushButtonData SlideOut_cnt10Panel_grp1_item3Data = new PushButtonData("SlideOut_cnt10Panel_grp1_item3", @"PushButton17", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton SlideOut_cnt10Panel_grp1_item3 = panel.AddItem(SlideOut_cnt10Panel_grp1_item3Data) as PushButton;
SlideOut_cnt10Panel_grp1_item3.ToolTip = @"PushButton 17 in SlideOut";
SlideOut_cnt10Panel_grp1_item3.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd.bmp");
TextBoxData SlideOut_cnt10Panel_grp1_item4Data = new TextBoxData("SlideOut_cnt10Panel_grp1_item4");
Autodesk.Revit.UI.TextBox SlideOut_cnt10Panel_grp1_item4 = panel.AddItem(SlideOut_cnt10Panel_grp1_item4Data) as Autodesk.Revit.UI.TextBox;
SlideOut_cnt10Panel_grp1_item4.ToolTip = @"TextBox 3 in SlideOut";
SlideOut_cnt10Panel_grp1_item4.Value = @"TextBox3";
SlideOut_cnt10Panel_grp1_item4.Image = BmpImageSource(@"RevitAddinCSProject.Resources.CheckAndUpdate.bmp");
SlideOut_cnt10Panel_grp1_item4.ShowImageAsButton = true;
SlideOut_cnt10Panel_grp1_item4.EnterPressed += CallbackOfTextBoxEnterPressed;
ComboBoxData SlideOut_cnt10Panel_grp1Data = new ComboBoxData("SlideOut_cnt10Panel_grp1");
Autodesk.Revit.UI.ComboBox SlideOut_cnt10Panel_grp1 = panel.AddItem(SlideOut_cnt10Panel_grp1Data) as Autodesk.Revit.UI.ComboBox;
SlideOut_cnt10Panel_grp1.ItemText = @"ComboBox2";
SlideOut_cnt10Panel_grp1.ToolTip = @"ComboBox 2 in SlideOut";
ComboBoxMemberData SlideOut_cnt10Panel_grp1_item1Data = new ComboBoxMemberData("SlideOut_cnt10Panel_grp1_item1", @"ComboBoxMember4");
ComboBoxMember SlideOut_cnt10Panel_grp1_item1 = SlideOut_cnt10Panel_grp1.AddItem(SlideOut_cnt10Panel_grp1_item1Data);
SlideOut_cnt10Panel_grp1_item1.ToolTip = @"ComboBoxMember 4 in ComboBox 2";
SlideOut_cnt10Panel_grp1_item1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smalla.bmp");
ComboBoxMemberData SlideOut_cnt10Panel_grp1_item2Data = new ComboBoxMemberData("SlideOut_cnt10Panel_grp1_item2", @"ComboboxMember5");
ComboBoxMember SlideOut_cnt10Panel_grp1_item2 = SlideOut_cnt10Panel_grp1.AddItem(SlideOut_cnt10Panel_grp1_item2Data);
SlideOut_cnt10Panel_grp1_item2.ToolTip = @"ComboBoxMember 5 in ComboBox 2";
SlideOut_cnt10Panel_grp1_item2.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smallb.bmp");
panel.AddSeparator();
}
public static void CallbackOfTextBoxEnterPressed(object sender, TextBoxEnterPressedEventArgs args)
{
}
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";
the exact same ribbons will be created and added to the Revit Ribbon:
All the above 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