Let’s see how to create a stacked group which holds various groups and items such as PulldownButton, PushButton, TextBox, ComboBox and ComboBoxMember 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 Stacked group is going to be created in a ribbon panel of our interest through specifying Begin as the start of the group, End as the last, and some group and items in between.
Please input necessary data for these groups and items as prompted, 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, the following code will be created:
public void AddRibbonItemsToRibbonPanel(RibbonPanel panel)
{
string assemFullName = Assembly.GetExecutingAssembly().Location;
string assemPath = Path.GetDirectoryName(assemFullName);
PushButtonData cnt1Stacked_grp0_item1Data = new PushButtonData("cnt1Stacked_grp0_item1", @"PushButton 1", assemFullName, "RevitAddinCSProject.ExtCmd1");
TextBoxData cnt1Stacked_grp0_item2Data = new TextBoxData("cnt1Stacked_grp0_item2");
PushButtonData cnt1Stacked_grp0_item3Data = new PushButtonData("cnt1Stacked_grp0_item3", @"PushButton 2", assemFullName, "RevitAddinCSProject.ExtCmd2");
IList<RibbonItem> cnt1Stacked = panel.AddStackedItems(cnt1Stacked_grp0_item1Data, cnt1Stacked_grp0_item2Data, cnt1Stacked_grp0_item3Data);
PushButton cnt1Stacked_grp0_item1 = cnt1Stacked[0] as PushButton;
cnt1Stacked_grp0_item1.ToolTip = @"PushButton 1 in Stacked 1";
cnt1Stacked_grp0_item1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smalla.bmp");
Autodesk.Revit.UI.TextBox cnt1Stacked_grp0_item2 = cnt1Stacked[1] as Autodesk.Revit.UI.TextBox;
cnt1Stacked_grp0_item2.ToolTip = @"TextBox 1 in Stacked 1";
cnt1Stacked_grp0_item2.Value = @"TextBox 1";
cnt1Stacked_grp0_item2.Image = BmpImageSource(@"RevitAddinCSProject.Resources.CheckAndUpdate.bmp");
cnt1Stacked_grp0_item2.ShowImageAsButton = true;
cnt1Stacked_grp0_item2.EnterPressed += CallbackOfTextBoxEnterPressed;
PushButton cnt1Stacked_grp0_item3 = cnt1Stacked[2] as PushButton;
cnt1Stacked_grp0_item3.ToolTip = @"PushButton 2 in Stacked 1";
cnt1Stacked_grp0_item3.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smallb.bmp");
TextBoxData cnt2Stacked_grp0_item1Data = new TextBoxData("cnt2Stacked_grp0_item1");
PulldownButtonData cnt2Stacked_grp1Data = new PulldownButtonData("cnt2Stacked_grp1", @"Pulldown 1");
ComboBoxData cnt2Stacked_grp2Data = new ComboBoxData("cnt2Stacked_grp2");
IList<RibbonItem> cnt2Stacked = panel.AddStackedItems(cnt2Stacked_grp0_item1Data, cnt2Stacked_grp1Data, cnt2Stacked_grp2Data);
Autodesk.Revit.UI.TextBox cnt2Stacked_grp0_item1 = cnt2Stacked[0] as Autodesk.Revit.UI.TextBox;
cnt2Stacked_grp0_item1.ToolTip = @"TextBox 2 in Stacked 2";
cnt2Stacked_grp0_item1.Value = @"TextBox 2";
cnt2Stacked_grp0_item1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.CheckAndUpdate.bmp");
cnt2Stacked_grp0_item1.ShowImageAsButton = true;
cnt2Stacked_grp0_item1.EnterPressed += CallbackOfTextBoxEnterPressed;
PulldownButton cnt2Stacked_grp1 = cnt2Stacked[1] as PulldownButton;
cnt2Stacked_grp1.ToolTip = @"Pulldown 1 in Stacked 2";
cnt2Stacked_grp1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd16x16.bmp");
PushButtonData cnt2Stacked_grp1_item1Data = new PushButtonData("cnt2Stacked_grp1_item1", @"PushButton 3", assemFullName, "RevitAddinCSProject.ExtCmd1");
PushButton cnt2Stacked_grp1_item1 = cnt2Stacked_grp1.AddPushButton(cnt2Stacked_grp1_item1Data) as PushButton;
cnt2Stacked_grp1_item1.ToolTip = @"PushButton 3 of Pulldown 1 in Stacked 2";
cnt2Stacked_grp1_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd16x16.bmp");
Autodesk.Revit.UI.ComboBox cnt2Stacked_grp2 = cnt2Stacked[2] as Autodesk.Revit.UI.ComboBox;
cnt2Stacked_grp2.ToolTip = @"ComboBox 1 in Stacked 2";
cnt2Stacked_grp2.Image = BmpImageSource(@"RevitAddinCSProject.Resources.groupsmall.bmp");
ComboBoxMemberData cnt2Stacked_grp2_item1Data = new ComboBoxMemberData("cnt2Stacked_grp2_item1", @"ComboBoxMember 1");
ComboBoxMember cnt2Stacked_grp2_item1 = cnt2Stacked_grp2.AddItem(cnt2Stacked_grp2_item1Data);
cnt2Stacked_grp2_item1.ToolTip = @"ComboBoxMember1 of ComboBox1 in Stacked 2";
cnt2Stacked_grp2_item1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd16x16.bmp");
}
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";
something like the following will be 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