Let’s see how to create ComboBox group and ComboBoxMember items using RevitAddinWizard.
After the Ribbon Creator tool of the Revit Addin Coder is clicked, the Ribbon Creator window will appear. Then we can indicate a ComboBox group is going to be created in a panel of interest through specifying Begin as the first Item, End as the last Item, and CombBoxMember and Separator items in between.
The Text and the Tooltip are enabled for ComboBox groups and the Image and the Command are disabled. Neither ComboBox nor CombBoxMember can call a command. Though the ComboBox group can still display its own image side by side with the one of the default or chosen ComboBoxMember, the Ribbon Creator does not support it to avoid confusion. It is nicer for the ComboBoxMember to show an image along with its Text and Tooltip. Since ComboBoxMember items only have chances to show small images, please remember to pick up a 16x16 pixels bitmap for each of them so that their look in the Revit Ribbon can be good.
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);
ComboBoxData cnt1Panel_grp1Data = new ComboBoxData("cnt1Panel_grp1");
Autodesk.Revit.UI.ComboBox cnt1Panel_grp1 = panel.AddItem(cnt1Panel_grp1Data) as Autodesk.Revit.UI.ComboBox;
cnt1Panel_grp1.ItemText = @"ComboBox";
cnt1Panel_grp1.ToolTip = @"Combo Box Tooltip";
ComboBoxMemberData cnt1Panel_grp1_item1Data = new ComboBoxMemberData("cnt1Panel_grp1_item1", @"ComboBoxMember1");
ComboBoxMember cnt1Panel_grp1_item1 = cnt1Panel_grp1.AddItem(cnt1Panel_grp1_item1Data);
cnt1Panel_grp1_item1.ToolTip = @"ComboBoxMember1 Tooltip";
cnt1Panel_grp1_item1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smalla.bmp");
ComboBoxMemberData cnt1Panel_grp1_item2Data = new ComboBoxMemberData("cnt1Panel_grp1_item2", @"ComboBoxMember2");
ComboBoxMember cnt1Panel_grp1_item2 = cnt1Panel_grp1.AddItem(cnt1Panel_grp1_item2Data);
cnt1Panel_grp1_item2.ToolTip = @"ComboBoxMember2 Tooltip";
cnt1Panel_grp1_item2.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smallb.bmp");
cnt1Panel_grp1.AddSeparator();
ComboBoxMemberData cnt1Panel_grp1_item4Data = new ComboBoxMemberData("cnt1Panel_grp1_item4", @"ComboBoxMember3");
ComboBoxMember cnt1Panel_grp1_item4 = cnt1Panel_grp1.AddItem(cnt1Panel_grp1_item4Data);
cnt1Panel_grp1_item4.ToolTip = @"ComboBoxMember3 Tooltip";
cnt1Panel_grp1_item4.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smallc.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 images really look like):
As can be seen, all the images of the ComboBoxMember items have been changed to something else other than the default image provide by the Ribbon Creator.
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