RevitLookup, Fishing and Sample Code
I started to learn the Revit API (using C#) with not much guidance. I would like to share in this post what I would tell someone starting to code with it - to save them some headaches. Here it goes:
Where to start
A very good way to start is to follow the “My First Revit Plug-in” tutorial from Autodesk. As stated there, you can start from it even if you don’t have coding experience:
This is a “one-stop shop” learning path for users who know Autodesk products but are absolutely new to programming and are thinking about taking the plunge
In my case, it was great to use this guide because even though I know how to code, C# was a new language for me.
The Docs With Examples
After you finish the guide from Autodesk, you will start to code your own projects. This is a point where you go to the documentation a lot to learn about the classes and their members.
If you google “Revit API docs” one of the first results will be revitapidocs.com. You will get links to that page when searching for any of the classes of methods. It’s a great page, but it doesn’t have a lot of examples.
I would recommend using apidocs.co instead. On every page on this site, look for the button with the code symbol on the top right. If you click it, you will get examples of the method of the current page.
Here is an example of how the examples pop after clicking:
Snoop Revit Elements
There is a tool that is a must-have to develop Revit addins. It is called RevitLookup, it is free, and you can find it here.
Whenever you read in a Revit API blog post people talking about “snooping” something, they refer to using this tool to inspect the content of an element in Revit. After installing the tool, test it by clicking an element and then clicking “Snoop Selection” (it’s one of the buttons of the tool dropdown).
Learning to Fish
I found this article from Jeremy Tammik where he explains how to search for things from the Revit API you don’t know. I would recommend reading it and following his advice.
If you download the Revit .NET SDK from the Autodesk website you will have all the code samples on your computer.