Walkthrough: Add Hello World Ribbon Panel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone, my name is Marcio Mortoni and I´m doing a walkthrough proposed by Autodesk.
I´ve done the first lesson called Walkthrough : Hello World,
After that, I've tried to continue doing the next step, called Add Hello World Ribbon Panel
I've done everything proposed, but in the end, it doesn't work, showing this message
For better understanding, follow the complete code
CsPanel.cs
using System;
using System.Reflection;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Windows.Media.Imaging;
namespace AddPanel
{
/// <remarks>
/// This application's main class. The class must be Public.
/// </remarks>
public class CsAddPanel : IExternalApplication
{
// Both OnStartup and OnShutdown must be implemented as public method
public Result OnStartup(UIControlledApplication application)
{
// Add a new ribbon panel
RibbonPanel ribbonPanel = application.CreateRibbonPanel("NewRibbonPanel");
// Create a push button to trigger a command add it to the ribbon panel.
string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
PushButtonData buttonData = new("cmdHelloWorld",
"Hello World", thisAssemblyPath, "AddPanel.HelloWorld");
PushButton pushButton = (PushButton)ribbonPanel.AddItem(buttonData);
// Optionally, other properties may be assigned to the button
// a) tool-tip
pushButton.ToolTip = "Say hello to the entire world.";
// b) large bitmap
Uri uriImage = new(@"C:\Users\Marcio Mortoni\OneDrive\01_Imagens\icones\trabalhador.png");
BitmapImage largeImage = new(uriImage);
pushButton.LargeImage = largeImage;
return Result.Succeeded;
}
public Result OnShutdown(UIControlledApplication application)
{
// nothing to clean up in this simple case
return Result.Succeeded;
}
}
/// <remarks>
/// The "HelloWorld" external command. The class must be Public.
/// </remarks>
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class HelloWorld : IExternalCommand
{
// The main Execute method (inherited from IExternalCommand) must be public
public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,
ref string message, ElementSet elements)
{
TaskDialog.Show("Revit","Hello World");
return Autodesk.Revit.UI.Result.Succeeded;
}
}
}
AddPanel.csproj
Manifest File HelloWorldRibbon