Introducing the Revit API

ABOUT THE CONTRIBUTING AUTHOR: DON RUDDER

Don Rudder is a BIM manager for HOK in the San Francisco office, for which he provides Revit customization development and support. Don has extensive experience in .NET and web development for the AEC industry. His background is primarily in the MEP disciplines where he has served as designer, CAD manager, and customization consultant.

Don maintains a blog focusing on all things Revit and especially the API at www.RevitNet.blogspot.com.

Revit 2012 officially supports two flavors of Microsoft .NET to handle your automation pleasures. Visual Studio for Applications (VSTA) is basically a lighter .NET API that can be embedded into Revit documents. The other flavor is an externally defined class library. This chapter focuses primarily on externally defined class libraries, since they generally have the fewest limitations.

While the Revit API may not be perfect, it is extremely powerful. The API is a heavily prioritized area of Revit that the folks at Autodesk are intensely focused on improving and expanding well into the future. If you have ideas or suggestions for the growth or improvement of API features, please don't be shy in creating an account on the https://beta.autodesk.com website. Request Revit as a BETA project. After you've been added to an Autodesk BETA project, you can request features and report problems, tracking them all the way through remediation. Any feedback you provide is always welcome.

Now Supporting .NET Framework 4.0

Our beloved Revit API now supports Microsoft's .NET Framework version 4.0 (www.microsoft.com/net) along with all of the latest .NET programming languages. Most of the sample projects found in the Revit 2012 SDK and online are written in C#. Since all .NET languages compile down to the same machine code, it is possible to write your projects in VB.NET, C#, or F#, all while providing the same functionality. The choice between .NET programming languages is purely up to the developer.

If you are using Visual Studio 2008 or earlier, you will not be able to debug Revit API projects for Revit 2012. You have to develop your projects in an environment that supports Microsoft .NET 4.0 such as Visual Studio 2010. You'll learn more about the supported Visual Studio development environment options later in this chapter.

Revit 2012 Software Development Kit

The Revit 2012 Software Development Kit (SDK) is a valuable resource containing documentation and Visual Studio sample projects that demonstrate how to do just about anything you can think of with the Revit API. The samples are updated fairly regularly and are an excellent starting point for getting your feet wet with the API. The “Getting Started with the Revit API” document included with the SDK will help you understand each of the SDK example projects.

The Revit SDK also ships with the installation package and is accessible from the Install Tools And Utilities button in the main installation dialog box, as shown in Figure 25.1. We recommend that you always try to work with the most recent version, which can be downloaded from the Autodesk website at www.autodesk.com/revit.

FIGURE 25.1 Installing the Revit SDK

image

The SDK's Revit Lookup Utility

After installing the Revit SDK, be sure to take a good look at the Revit Lookup utility. The Revit Lookup utility, formerly known as RvtMgdDbg, is by far the most useful sample project in the SDK. As you learn to develop in Revit, this tool will be your guiding light. It allows you to peek inside a model or family document and truly inspect the inner workings behind the scenes. It also identifies what elements and properties are accessible through the API and generally how to gain access to them.

Build the sample project (RevitLookup.dll) and copy it into the addins directory to use the utility in your Revit sessions. An installation manifest is included in the sample project named RevitLookup.addin. Once you have compiled and installed the utility, a ribbon drop-down menu to access the tool is available, as shown in Figure 25.2.

FIGURE 25.2 Accessing Revit Lookup from the ribbon

image

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset