Let's start opening the basic template here.
Take a look to the code:
The first thing you need to do is to set your application for creating a new ribbon tab:
public class Applicationclass : IExternalApplication
{
#region IExternalApplication Members
public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication application)
{
string path = Assembly.GetExecutingAssembly().Location; //<-----The path of the dll file for your addin
//add code here if you want to run functions on Revit Startup
//Set the contextual help which show help file pushing "F1"
ContextualHelp help = new ContextualHelp(ContextualHelpType.Url, "YOUR URL HERE");
//Create a new Ribbon tab
application.CreateRibbonTab("THE_TAB_NAME");
//Create a new Ribbon Panel inside the ribbon tab
RibbonPanel panel = application.CreateRibbonPanel("THE_TAB_NAME", "THE_PANEL_NAME");
//Create a new button and insert it into the panel
//btn1 = a unique identifier for the button
//Name_Button= The name of the button you want to be shown
//path = the path of the addin dll file
//Classname = the full class name for your command
PushButtonData manag = new PushButtonData("btn1", "Name_BUTTON", path, "Revit_AppWithCustomRibbon.YOURCOMMAND");
//set the contextual help for your command
manag.SetContextualHelp(help);
//add the button to the panel
panel.AddItem(manag);
return Result.Succeeded;
}
public Autodesk.Revit.UI.Result OnShutdown(UIControlledApplication application)
{
//Remove events if needed
return Result.Succeeded;
}
#endregion
}
Now you are able to create your commands as I shown here:
//Add your external commands here or in another file
[Autodesk.Revit.Attributes.Transaction(
Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class YOURCOMMAND : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
TaskDialog.Show("Hello", "Hello world!");
return Result.Succeeded;
}
}
Here the Code