Getting Started with the Revit 2012 API

We already published ‘Getting Started with the Revit API’ guides for

Revit 2009
and

2010
.
Here is a completely revamped and much expanded version for Revit 2012.
Actually, before even reading any further on this page, go to the
Revit Developer Center
and see what material is available there.
That is always the most up-to-date place to look.
Still, this overview may help your orientation as well:

Getting Started with the Revit 2012 API

1. Setting up the Environment

The first step is to obtain and set up a development environment.
This includes the Revit product itself, the Revit API, the Revit SDK (Software Developer Kit), and the development environment.

Revit Product: You can download the latest version of released products from the Autodesk product page.
Go to www.autodesk.com, look under the ‘Products’ menu, ‘Alphabetically.’
From each Revit product page, look under Product Download.
Following are examples of the links at the time of writing (Note: exact link may change):

Without an activation code, you can use Revit in viewing-only mode.

Revit API: The Revit API is provided by the .NET assemblies RevitAPI.dll and RevitAPIUI.dll, which are present in every Revit installation under

<Revit install>Program

Revit SDK: The Revit SDK is included in every Revit installation.

The SDK installation can be launched from the ‘Install Tools and Utilities’ menu on the main page of the Revit installer.
There is another menu called ‘Utilities’ you see right after the product installation, which contains only the link ‘Content Batch Utilities’.
Click on the ‘Back to First Page’ button to move back to the main page of the installer to install the SDK.

Alternatively, you can also find the SDK in the extraction folder, under:

<extraction folder>supportSDKRevitSDK.exe

If you have accepted the default location, it typically looks like this:

C:Program FilesAutodeskRevit XXX 2012supportSDKRevitSDK.exe

Note that the SDK may be updated by intermediate releases.
Make sure you check for the latest version either on the members-only ADN site or the public
Revit Developer Center.

The SDK includes Revit API documentation.
The most important items are the Revit API help file RevitAPI.chm and the developer guide “Revit 2012 API Developer Guide.pdf”.
It also includes many samples.

Development Environment: Microsoft Visual Studio (MSVS) 2010 for Revit 2012.
You may also use VS 2008 + SP1, but debugging a Revit 2012 add-in does not work in that environment.
All the SDK samples are provided for VS 2010.
The Visual Studio Express editions can also be used.

2. Where to Start

(1) Watch the training video – The best way to start is to watch our DevTV recording, posted towards the bottom on the
Revit Developer Center.

If you are new to programming in general as well, take a look at the
My First Revit Plug-in training material.

You can also have a look at last year’s
Revit 2011 API webcast recording.

It covers the basics of the Revit API since 2011.
Note that the Revit API underwent a major renovation in 2011.
The webcast materials include the recording itself, the Powerpoint presentation, and training labs code.
You can also find it on the ADN web site, under the Revit knowledgebase section, or from the Developer Center

Training Course Schedule
and

Webcast Archive
.

The latest training labs for Revit 2012 are posted on the
Revit Developer Center.

This year’s Revit 2012 API webcast covers several major API enhancements.

If you are interested in Family API, there is a

Revit Family API webcast recording
, too.

(2) Work through the latest hands-on training labs, which are available from the
Revit Developer Center
(scroll down toward the bottom).

(3) Try implementing and running the HelloRevit sample by yourself, for example following the steps described in Chapter 2, Walkthroughs, in the developer guide.
Go through the Labs code, and look at some Revit SDK samples.
The following SDK samples will be a good starting point:

  • RevitCommands
  • Fire Rating
  • Viewers/ElementViewer
  • CreateBeamsColumnsBraces

3. For More Information

  • The Building Coder Revit API blog, also accessible through
    blogs.autodesk.com/thebuildingcoder, and especially its
    Getting Started category.
  • AEC DevCamp 2010:
    AEC DevCamp is a bi-annual event. This link includes the comprehensive set of materials up to the Revit 2011 API and is of interest to both beginners and advanced developers.
    Look under Revit Track 1 (Beginner) and Track 2 (Advanced), contained in the folders starting with 1.x or 2.x.
  • Autodesk University: AU 2007/2008/2009/2010 –
    go to the ‘Online Classes’ tab.
    Search for ‘Revit API’ and/or under the Developer and Customization tracks.
    You should be able to sign up and have access to those materials.
    For example, here are a few classes from AU2010 presented by Revit API engineers and the Developer Technical Services team whose materials give you additional, more in-depth information:

    • CP319-1
      Analyzing Building Geometry using the Revit API – Scott Conover
    • CP327-1
      Using Dynamic Model Update in the Revit API – Scott Conover
    • CP234-2
      Revit 2011 Programming Optimization – Jeremy Tammik
    • CP228-2
      Optimal Use of Revit 2011 Programming Features – Jeremy Tammik
    • CP316-1
      Presenting Analysis Data in Revit 2011 – Harry Mattison

    There is much more.
    Please search the AU site.

  • Autodesk Revit API Discussion Group:
    go to forums.autodesk.com and select Revit > Revit API.
  • ADN members-only web site: provided by the Autodesk Developer Network.

    • Search DevNotes, whitepapers, and Q&A pages
    • Submit questions through DevHelp Online

    If you are currently not an ADN member and interested in joining, please refer to
    becoming an ADN member.

4. .NET, C# and Books

In a followup to the note on

removing an add-in registered by the wizard
,
Bryan Thatcher asks:

Question: I have programming experience starting with Qbasic, VBA, VB5, some C and C++, but I’m new to C# and the added complexity of the Revit API has been a challenge.
I have learned a lot from your blog, but can you recommend a comprehensive resource for the Revit API as it relates to C#?
All of the material I’ve found so far has been fragmented.

Answer: I can suggest very little regarding books on this topic.
The only books I read myself are novels :-)

I mentioned this

.NET learning resource
back in 2009, and some

free .NET development and architecture e-books
in 2010.

I would not worry much about the fragmentation, though.
.NET and C# is one thing, the Revit API another.

I would suggest learning C# independently of Revit using any free online tutorial you like, working through the Revit getting started materials bit by bit at the same time, and Bob’s your uncle.
The DevTV tutorials are extremely easy to follow, require only minimal .NET and programming knowledge, and familiarise you with it step by step as you go along.

Look at the material listed above, and for more, there is the whole

getting started
category of this blog.


Comments

11 responses to “Getting Started with the Revit 2012 API”

  1. Hi Jeremy,
    Please help me to highlight Elements in Revit Structure 2012 through API.
    Thanks,

  2. Hi,
    I am a c# developer.I have a .net application from which i have to access a revit file and add it to the application.I also need to view this file from my application.Is it possible for an external application to access Revit,other than adding a plugin to revit?
    I am able to create an addin in Revit for my application.Now i want to do vice versa!Please Help
    Neethu

  3. Hi,
    Thanks for providing us with this informative blog. I ran into a problem that all of the sample projects that I compile for Revit 2012 have their ribbon buttons disabled. Building addins for 2011 used to work fine. Does anybody have an idea what might be the cause of this problem?
    Thanks in advance.
    Kind regards,
    Thomas

  4. Dear Thomas,
    Thank you for your appreciation!
    I have not heard of that problem.
    All I know about greyed out command buttons is summarised in
    http://thebuildingcoder.typepad.com/blog/2009/06/rfa-version-grey-commands-family-context-and-rdb-link.html#2
    Jean-François Breton added some explanations to the comments there as well.
    Cheers, Jeremy.

  5. Dear Neethu,
    Sorry, the Revit API is only available within the context of the callbacks that it defines, so you must define an add-in implementing an external application or command to use it, cf.
    http://thebuildingcoder.typepad.com/blog/2010/04/asynchronous-api-calls-and-idling.html
    Cheers, Jeremy.

  6. Dear Sangsen,
    Your question is answered here:
    http://thebuildingcoder.typepad.com/blog/2010/06/highlight-elements.html
    Cheers, Jeremy.

  7. Dear Jeremy,
    I just started using Revit .NET API to create an add-in. the add-in shows a form and returns the control to Revit. the form remains open waiting for user to put something and click a button.
    after pressing the button, an Instance Shared Parameter will be created for selected object on the form and a value will be assigned to the parameter.
    problem: value will be shown in the property panel, but after saving property returns to the previous value !!
    tried to use Transaction, but get ‘Sharing Violation Exception’.
    looked for ‘Application Lock’ (the same thing we have in AutoCad) but no luck!
    will be appreciated if you give me some information or guidance.
    Regards,
    Afshin

  8. Dear Afshin,
    Your form is modeless. Big problem. Read
    http://thebuildingcoder.typepad.com/blog/2011/09/yet-another-modeless-update.html
    There are many posts preceding it which also discuss this problem and how to address it in yet more depth.
    Cheers, Jeremy.

  9. Dear Jeremy,
    Thank you very much for the help :)
    I really didn’t read the whole stories, but the ‘idleUpdate’ event handler solved the whole problem so far. btw, I will be one of your readers from now on :)
    I really appreciate your brilliant work and again, Thanks.
    Cheers,
    Afshin

  10. i should install ravit 2012 but installation in problem because in this show some message (Rapid RTP Shader Interface.dll)file is corrupted so give me solve my problem.

  11. Dear Ashray,
    No, sorry, I cannot help you with installation issues. Please ask product support. And I would suggest installing the current version, Revit 2014. It offers significant improvements in all areas.
    Cheers, Jeremy.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading