CreateRibbonPanel Method (String)


Create a new RibbonPanel on the Add-Ins tab.

Namespace: Autodesk.Revit.UI
Assembly: RevitAPIUI (in RevitAPIUI.dll) Version: 2015.0.0.0 (2015.0.0.0)

Syntax

C#
public virtual RibbonPanel CreateRibbonPanel(
	string panelName
)
Visual Basic
Public Overridable Function CreateRibbonPanel ( _
	panelName As String _
) As RibbonPanel
Visual C++
public:
virtual RibbonPanel^ CreateRibbonPanel(
	String^ panelName
)

Parameters

panelName
Type: System String
The name of the panel to be created.

Remarks

This method will create a custom panel appending to the Revit AddIns tab. This method is not supported in Macros.

Examples

Copy C#
public Result OnStartup(UIControlledApplication application)
{
    // add new ribbon panel
    RibbonPanel ribbonPanel = application.CreateRibbonPanel("NewRibbonPanel");

    //Create a push button in the ribbon panel “NewRibbonPanel”
    //the add-in application “HelloWorld” will be triggered when button is pushed

    PushButton pushButton = ribbonPanel.AddItem(new PushButtonData("HelloWorld", 
        "HelloWorld", @"D:\HelloWorld.dll", "HelloWorld.CsHelloWorld")) as PushButton;

    // Set the large image shown on button
    Uri uriImage = new Uri(@"D:\Sample\HelloWorld\bin\Debug\39-Globe_32x32.png");
    BitmapImage largeImage = new BitmapImage(uriImage);
    pushButton.LargeImage = largeImage;


    return Result.Succeeded;
}
Copy VB.NET
Public Function OnStartup(application As UIControlledApplication) As Autodesk.Revit.UI.Result Implements IExternalApplication.OnStartup
    ' add new ribbon panel
    Dim ribbonPanel As RibbonPanel = application.CreateRibbonPanel("NewRibbonPanel")

    'Create a push button in the ribbon panel “NewRibbonPanel”
    'the add-in application “HelloWorld” will be triggered when button is pushed


    Dim pushButton As PushButton = TryCast(ribbonPanel.AddItem(New PushButtonData("HelloWorld", "HelloWorld", "D:\HelloWorld.dll", "HelloWorld.CsHelloWorld")), PushButton)

    ' Set the large image shown on button
    Dim uriImage As New Uri("D:\Sample\HelloWorld\bin\Debug\39-Globe_32x32.png")
    Dim largeImage As New BitmapImage(uriImage)
    pushButton.LargeImage = largeImage


    Return Result.Succeeded
End Function

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentNullException panelName is a null reference ( Nothing in Visual Basic) .
Autodesk.Revit.Exceptions ArgumentException panelName is Empty.
Autodesk.Revit.Exceptions InvalidOperationException If more than 100 panels were created.

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →