Creating Macros with
Revit VSTA
This topic explains how to create macros in Revit. We will describe macro capabilities, the overall workflow, specific
installation steps, a development environment called Revit VSTA, code examples, frequently asked questions, and related
information about the Revit SDK.
Getting Started with Macros
First, let's answer the question: "what are macros, and why would you use them"? Macros are programs that
are designed to help you save time, by automating repetitive tasks. Each macro performs a series of pre-defined
steps to accomplish a particular task. The steps should be repeatable and the actions predictable.
For example, you might define a macro to add a grid to your project, to rotate a selected object, or to collect
information about the square footage of all the rooms in your structure. Other general examples include:
Locating and extracting Revit content to external files
Tweaking geometry or parameters
Creating many types of elements
Importing and exporting external file formats
Revit provides an Application Programming Interface (API) that allows you to extend the functionality of
the product. Experienced developers and Autodesk partners may already know that the Revit API lets them
add customized commands to the Tools
In addition to those API extensions, starting in the Revit 2009 release you can use the API to define macros
that run in Revit. Unlike external commands and external applications, the macro functionality is available
to Revit after you install an "add-in" called Revit VSTA. We will explain the API differences later in this topic,
but for experienced developers, note that you do not need to register the macros in Revit.ini, or add
RevitAPI.dll as a reference.
VSTA is an acronym for Visual Studio Tools for Applications. It is a Microsoft technology that provides the
.NET framework for creating macros in C# and VB.NET based on specific applications. VSTA is the next
evolution of Visual Basic for Applications (VBA) that appears in several existing Autodesk applications.
External Commands menu, or add new menus and toolbars.
24
1339
Need help?
Do you have a question about the 24000-000000-9860 - Revit Architecture - PC and is the answer not in the manual?
Questions and answers