Walkthrough: Add Hello World Ribbon Panel

Walkthrough: Add Hello World Ribbon Panel

id8656
Explorer Explorer
310 Views
3 Replies
Message 1 of 4

Walkthrough: Add Hello World Ribbon Panel

id8656
Explorer
Explorer

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, 

https://help.autodesk.com/view/RVT/2025/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Introduction_...

 

After that, I've tried to continue doing the next step, called Add Hello World Ribbon Panel

https://help.autodesk.com/view/RVT/2025/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Introduction_...

 

I've done everything proposed, but in the end, it doesn't work, showing this message

 

id8656_0-1737565455521.png

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

 

<Project Sdk="Microsoft.NET.Sdk">
 
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <Platforms>AnyCPU;x64</Platforms>
    <ApplicationManifest>HelloWorldRibbon.addin</ApplicationManifest>
  </PropertyGroup>
 
  <ItemGroup>
    <Reference Include="RevitAPI">
      <HintPath>..\..\..\..\..\..\Program Files\Autodesk\Revit 2024\RevitAPI.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="RevitAPIUI">
      <HintPath>..\..\..\..\..\..\Program Files\Autodesk\Revit 2024\RevitAPIUI.dll</HintPath>
      <Private>False</Private>
    </Reference>
  </ItemGroup>
 
<ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
</ItemGroup>
 
</Project>

 

 

Manifest File HelloWorldRibbon

 

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<RevitAddIns>
<AddIn Type="Application">
<Name>Hello World Panel</Name>
<Assembly>C:\Users\Marcio Mortoni\source\repos\AddPanel\AddPanel\bin\x64\Debug\net8.0\AddPanel.dll</Assembly>
<AddInId>3ADE477A-9801-4576-8D13-3893689B6EE6</AddInId>
<FullClassName>AddPanel.CsAddPanel</FullClassName>
<VendorId>MORTONI</VendorId>
<VendorDescription>TheBest</VendorDescription>
</AddIn>
</RevitAddIns>
 

 

0 Likes
311 Views
3 Replies
Replies (3)
Message 2 of 4

ricaun
Advisor
Advisor

What Revit version are you testing?

What error show in the 'Show details'?

 

There is a inconsistent version configuration in your file, you are using Revit 2024 API reference and that implies you are using Revit 2024. If that the case your code is build in the TargetFramework net8.0 and is not supported in Revit 2024 only net4.8.

 

If you change to '<TargetFramework>net48</TargetFramework>' if you are running in Revit 2024.

 

Or follow Walkthrough for Revit 2024.

https://help.autodesk.com/view/RVT/2024/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Introduction_...

 

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Message 3 of 4

id8656
Explorer
Explorer

Hey Rica, I'm sorry I didn't send all the information.

What Revit version are you testing? 2024

What error show in the 'Show details'?

 

id8656_0-1737574474802.png

 

I´m gonna try your solution and I will return asap

 

Thanks for your help.

 

Marcio Mortoni

 

 

0 Likes
Message 4 of 4

id8656
Explorer
Explorer

Unfortunately, It didn't work. I've researched and there´s no video about this tutorial in the internet

0 Likes