Let’s see how to create SlideOut and its members such as PushButton and SplitButton 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 SlideOut is going to be created in a panel of interest through specifying SlideOut as the container. No Begin or End items for the SlideOut container is necessary as a Revit ribbon panel (RibbonPanel) can have only one SlideOut and after it is added to the panel everything will be held by the SlideOut from that moment on.
Except for the SlideOut container, all other ribbon groups or items are specified the same way as if they are held directly by panels. In this example, only PushButton and SplitButton are demonstrated, but of course more groups and items can be specified following the SlideOut container in the Ribbon Creator window, for example, TextBox, ComboBox and ComboBoxMember, PulldownButton, and even stacked groups.
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", @"PushButton 1", assemFullName, "RevitAddinCSProject.ExtCmd");
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.ExtCmd.bmp");
PushButtonData cnt1Panel_grp0_item2Data = new PushButtonData("cnt1Panel_grp0_item2", @"PushButton 2", assemFullName, "RevitAddinCSProject.ExtCmd");
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.ExtCmd.bmp");
panel.AddSlideOut();
PushButtonData cnt2SlideOut_grp0_item1Data = new PushButtonData("cnt2SlideOut_grp0_item1", @"PushButton 3", assemFullName, "RevitAddinCSProject.ExtCmd1");
PushButton cnt2SlideOut_grp0_item1 = panel.AddItem(cnt2SlideOut_grp0_item1Data) as PushButton;
cnt2SlideOut_grp0_item1.ToolTip = @"PushButton 3 In SlideOut";
cnt2SlideOut_grp0_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd.bmp");
PushButtonData cnt2SlideOut_grp0_item2Data = new PushButtonData("cnt2SlideOut_grp0_item2", @"PushButton 4", assemFullName, "RevitAddinCSProject.ExtCmd2");
PushButton cnt2SlideOut_grp0_item2 = panel.AddItem(cnt2SlideOut_grp0_item2Data) as PushButton;
cnt2SlideOut_grp0_item2.ToolTip = @"PushButton 4 In SlideOut";
cnt2SlideOut_grp0_item2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd.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", @"PushButton 5", assemFullName, "RevitAddinCSProject.ExtCmd3");
PushButton cnt3Panel_grp1_item1 = cnt3Panel_grp1.AddPushButton(cnt3Panel_grp1_item1Data) as PushButton;
cnt3Panel_grp1_item1.ToolTip = @"PushButton 5 of Pulldown In SlideOut";
cnt3Panel_grp1_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd.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):
All PushButton items use the default images provide by the Ribbon Creator but they can be changed to anything else.
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