Getting Started with Revit API
There are plenty of ways to share development efforts with others - Dynamo Graphs, Revit Macros, Revit Add-Ins, oh my!
We’ll work with Revit Add-Ins for most of this blog, and our first coding post will start at the beginning - adding buttons : ]
Getting Set Up
1. An IDE (Integrated Development Environment - I’ll use Visual Studio Community) - this is where you’ll write code and build your add-in (Download here)
2. An installation of Revit - this is where we’ll test that our code works (Purchase and download here)
3. A favorite programming language (I’ll be working with C#, most of the Revit API community uses this so we should be consistent).
4. Here are some helpful links:
Autodesk Developer Network - Forums and lots of experts here!
SDKs - Sample code and CHM reference for what is available through the Revit API
The Building Coder - Jeremy Tammik, Autodesk’s own voice for Revit API
Boost your BIM - Harry Mattison, an independent blogger and strong voice for Revit API
Once all of those are appropriately set up, we can start coding! …sort of. We’ll need to configure a few things in a specific way:
1. Project(s) are created as Class Libraries, built on .NET Framework
2. Projects are built on the correct version of .NET Framework for your version of Revit (Revit 2019 uses .NET Framework 4.7). In Solution Explorer -> Project -> Properties -> Application
3. Use Managed Compatibility Mode on, Debug tab -> Options -> General
4. Add your references in Solution Explorer -> Project -> References:
To interact with things in Revit, you’ll need: RevitAPI & RevitAPIUI
To add buttons and other controls, you’ll need: AdWindows & PresentationCore & PresentationFramework & WindowsBase
And now that that’s out of the way, we can get to the fun stuff!