The SlideOut seems a fancy feature in the Revit Ribbon but in the API it’s nothing fancy at all. Instead, it’s pretty the same as the Separator we talked about before. It does not have a class assigned either and no control over it is exposed. Maybe it is good for developers as they do not have to worry about the behaviour of the SlideOut at all.
The AddSlideOut() method will add a SlideOut panel and from that moment on all items will be added to the group. It seems a lot of things are happening behind the scene but its use is very simple, just like the AddSeparator ().
So in the following code, we only replaced the AddSeparator() with the AddSlideOut():
private void AddRadioButtonGroupsAndPutTheSecondIntoSlideOut(RibbonPanel panel)
{
string assemFullName = Assembly.GetExecutingAssembly().Location;
string assemPath = Path.GetDirectoryName(assemFullName);
RadioButtonGroupData rbgData1 = new RadioButtonGroupData("RadioButtonGroup1");
RadioButtonGroup rbGroup1 = panel.AddItem(rbgData1) as RadioButtonGroup;
ToggleButtonData rb1MemData1 = new ToggleButtonData("rbg1Mem1", "Toggle11", assemFullName, "RevitAddinCSProject.ExtCmd1");
ToggleButton rb1Mem1 = rbGroup1.AddItem(rb1MemData1);
rb1Mem1.Image = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_16x16.bmp");
rb1Mem1.LargeImage = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_32x32.bmp");
ToggleButtonData rb1MemData2 = new ToggleButtonData("rbg1Mem2", "Toggle12", assemFullName, "RevitAddinCSProject.ExtCmd2");
ToggleButton rb1Mem2 = rbGroup1.AddItem(rb1MemData2);
rb1Mem2.Image = new BitmapImage(new Uri(Path.Combine(assemPath, "Standalone_Item1_16x16.bmp"), UriKind.Absolute));
rb1Mem2.LargeImage = new BitmapImage(new Uri(Path.Combine(assemPath, "Standalone_Item1_32x32.bmp"), UriKind.Absolute));
ToggleButtonData rb1MemData3 = new ToggleButtonData("rbg1Mem3", "Toggle13", assemFullName, "RevitAddinCSProject.ExtCmd3");
ToggleButton rb1Mem3 = rbGroup1.AddItem(rb1MemData3);
rb1Mem3.Image = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item2_16x16.bmp");
rb1Mem3.LargeImage = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item2_32x32.bmp");
panel.AddSlideOut();
RadioButtonGroupData rbgData2 = new RadioButtonGroupData("RadioButtonGroup2");
RadioButtonGroup rbGroup2 = panel.AddItem(rbgData2) as RadioButtonGroup;
ToggleButtonData rb2MemData1 = new ToggleButtonData("rbg2Mem1", "Toggle21", assemFullName, "RevitAddinCSProject.ExtCmd1");
ToggleButton rb2Mem1 = rbGroup2.AddItem(rb2MemData1);
rb2Mem1.Image = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_16x16.bmp");
rb2Mem1.LargeImage = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_32x32.bmp");
ToggleButtonData rb2MemData2 = new ToggleButtonData("rbg2Mem2", "Toggle22", assemFullName, "RevitAddinCSProject.ExtCmd2");
ToggleButton rb2Mem2 = rbGroup2.AddItem(rb2MemData2);
rb2Mem2.Image = new BitmapImage(new Uri(Path.Combine(assemPath, "Standalone_Item1_16x16.bmp"), UriKind.Absolute));
rb2Mem2.LargeImage = new BitmapImage(new Uri(Path.Combine(assemPath, "Standalone_Item1_32x32.bmp"), UriKind.Absolute));
ToggleButtonData rb2MemData3 = new ToggleButtonData("rbg2Mem3", "Toggle23", assemFullName, "RevitAddinCSProject.ExtCmd3");
ToggleButton rb2Mem3 = rbGroup2.AddItem(rb2MemData3);
rb2Mem3.Image = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item2_16x16.bmp");
rb2Mem3.LargeImage = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item2_32x32.bmp");
}
Then the two radio button groups would look very different:
Revit Ribbon API also provides some means to find all custom ribbon panels in the UIApplication and to iterate through all RibbonItem in each RibbonPanel. Rather than only showing a simple message, the external command 1 has been updated to show all ComboBox information in all third party AddIn panels:
try
{
//TODO: add your code below.
//MessageBox.Show("Command 1");
List<RibbonPanel> allAddinPanels = CachedUiApp.GetRibbonPanels();
string comboNames = "";
foreach(RibbonPanel panel in allAddinPanels)
{
foreach (RibbonItem item in panel.GetItems())
{
if (item.ItemType == RibbonItemType.ComboBox)
{
comboNames += string.Format("ComboBox {0} in RibbonPanel {1}\n", item.Name, panel.Name);
}
}
}
MessageBox.Show(comboNames, "ComboBox in all Addin Panels");
return Result.Succeeded;
}
The GetRibbonPanels() has another signature which supports a Tab argument. In the Revit API 2011 now, only the AddIns and the Analyze enumerators are provided.
The RibbonItem can be examined for its type:
• PushButton
• PulldownButton
• SplitButton
• ToggleButton
• RadioButtonGroup
• ComboBoxMember
• ComboBox
• TextBox
As mentioned in the previous post, there is no way to find to which group the RibbonItem belongs once it’s added to a group, like stacked items. Of course, if really necessary, some naming conversion can be applied for this purpose, e.g. StackedGroup1_ComboBox1, StackedGroup2_TextBox3, etc.
The RevitAddinWizard can help create all these ribbon code and actually much more automatically in a few seconds.
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