Revit API 2025

Revit API 2025

csuarezUPUMF
Observer Observer
135 Views
3 Replies
Message 1 of 4

Revit API 2025

csuarezUPUMF
Observer
Observer

Run button in macro manager does not activate, after I write a code. I can´t run the macro. I use Visual studio Code

0 Likes
Accepted solutions (1)
136 Views
3 Replies
Replies (3)
Message 2 of 4

Mohamed_Arshad
Advisor
Advisor

Hi @csuarezUPUMF 

 

You need to select the macro instead of module, then it will activated. Kindly check the below GIF for additional reference.

Sample (.gif)

Mohamed_Arshad_0-1758334990218.gif

Hope this will helps 🙂


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes
Message 3 of 4

csuarezUPUMF
Observer
Observer

Yes, I do that in 2021 to 2024 versions, but I currently use 2025 version it´s not the same

csuarezUPUMF_0-1758470713849.png

 

0 Likes
Message 4 of 4

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @csuarezUPUMF ,

 

I opened the macro in Visual Studio Code and wrote the following code.

using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace HelloWorld
{
   [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
   [Autodesk.Revit.DB.Macros.AddInId("4886F77D-6046-4C75-9845-0BC125EC75FA")]
   public partial class ThisApplication
   {
      private void Module_Startup(object? sender, EventArgs e)
      {
         
      }

      private void Module_Shutdown(object? sender, EventArgs e)
      {
      }

      //Comment out below method to add a sample Macro
      public void SampleMacro()
      {      	
         TaskDialog.Show("Title", "Hello World");  
      }
   }
}


I have a method called SampleMacro(). After navigating to the terminal in VS Code and running dotnet build, the solution built successfully, and I could see SampleMacro in the Macro Manager in Revit.
MACRO.png

I believe the reason your macro method is not visible in the Macro Manager is that the code may have been written inside Module_Startup() or Module_Shutdown(). Code in these methods runs automatically when Revit starts or closes, rather than appearing as a selectable macro.


To make your method visible in the Macro Manager, you should create it as a separate method. This way, it can be executed directly from the Macro Manager, similar to how an IExternalCommand works.


Could you please try placing your code in a separate method, similar to SampleMacro(), and let me know if it becomes visible?


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes