There are two different ways to work with the Revit API. In general, the code you write will be the same or almost the same in either case. Developing a macro is easier and simpler, but the trade-off is that you are limited in the development tools you use and how you share the macros with other people. Developing Add-Ins involves more set-up and some technical mumbo-jumbo to register the add-ins with Revit. A main upside of Add-Ins is that you are better able to distribute them to other people.
Here’s a quick review:
Macros
SharpDevelop, a free and open-source development environment (known as an Integrated Development Environment, or IDE), is included in the Revit install. It is automatically connected to Revit so the process of creating macros is relatively simple. SharpDevelop is OK, but many people would rather use Microsoft Visual Studio. But to develop macros you must use SharpDevelop.
Macros are automatically registered with Revit when you compile your code in SharpDevelop. The macros are listed in the Macro Manager which is the UI that you must use to run them.
The code for your macro is stored in an RVT file if it is a document macro. If you create an application macro the code is stored independently on your computer. For the application macro examples I have been developing for this blog, Revit stores the source at C:\ProgramData\Autodesk\Revit\Macros\2013\Architecture\VstaMacros\AppHookup\BoostYourBIM\Source\BoostYourBIM.
You can share your macros with other people either by sending them the RVT file (if it is a document macro) or sending them the source code (but that will take a bit of effort on their part to create a macro on their install of Revit to generate the same macro.
Add-Ins
Add-Ins are developed externally to Revit, usually using Microsoft Visual Studio, the free version called Visual Studio Express, or some other IDE.
The code for your Add-In gets compiled into a DLL file. An ADDIN file needs to be created so that Revit can discover the DLL. The ADDIN file goes into a place like C:\Users\HP002\AppData\Roaming\Autodesk\revit\Addins\2013. The ADDIN and DLL can be distributed to other users to let them run the command.
great explaination! appreciate it!
I noticed that the Add-In runs a little faster than the Macro in some cases with the same code and Visual Express is more stable than SharpDevelop (still don’t like it).
[…] What’s the difference between macro and Add-in: https://boostyourbim.wordpress.com/2012/12/05/macros-vs-add-ins-whats-the-difference/ […]
Thank you! In the case of a document macro,
(“The code for your macro is stored in an RVT file if it is a document macro”)
and the RVT file is in Revit 2020, could I open the file in Revit 2021 and use the macros, or do the macros should be updated to the Revit 2021 version?
Thanks for your help!
Maria
Autodesk occasionally makes changes to the Revit API that would require you to update the macro code. In general they will mark the existing method as obsolete for at least one release before removing it. While it is obsolete it will continue to work just fine but there will be a compiler warning to let you know it is obsolete. You can see the API changes in 2021 at https://thebuildingcoder.typepad.com/blog/2020/04/whats-new-in-the-revit-2021-api.html#4.1
Ahhhhhhhhh OK, I understand, so it affects to macros and to Add-ins similarly…
I though I could avoid it better, if I build macros instead of Add-ins, thanks for your help! 🙂
the underlying API is the same no matter how you access it (add-in, macro, dynamo) so if the API is obsolete or changed there is no getting around updating your code
Thanks a lot for your explanation, very useful.