Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Run button in macro manager does not activate, after I write a code. I can´t run the macro. I use Visual studio Code
Solved! Go to Solution.
Run button in macro manager does not activate, after I write a code. I can´t run the macro. I use Visual studio Code
Solved! Go to Solution.
You need to select the macro instead of module, then it will activated. Kindly check the below GIF for additional reference.
Sample (.gif)
Hope this will helps 🙂
Yes, I do that in 2021 to 2024 versions, but I currently use 2025 version it´s not the same
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.
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?