By now, I’m sure you’ve heard the term “API”, but what does it mean? More specifically, what is the Revit API?
A.P.I. is an acronym for “application programming interface”. In simpler terms, it is what software developers use to interact with an existing piece of software. Developers can use API’s to:
-Execute commands on software programmatically
-Bridge two pieces of software so they can “talk to each other”
-Extract raw data from a database that another application maintains.
In regards to the Revit API, software developers have been leveraging this interface to build Revit add-ins and even Dynamo graphs. Yes, even Dynamo uses the Revit API to make changes or extract information from RVTs.
Learning the Revit API is exceptionally difficult if you don’t have experience in writing code, but here are a few simple tips that will help you get started on automating some repetitive tasks or extracting data from Revit models.
For those of you that don’t know how to code: Learn Dynamo
Dynamo is a great way to tap into the Revit API because rather than writing code, you can handle powerful tasks using nodes. In software developer lingo, a node is like a function or method and is used to manipulate or extract data out of a Revit model.
Although developers have the ability to create custom nodes using programming languages to speak to the Revit API (typically C# and Python), the good news is, you can create powerful scripts without writing a single line of code because all of the code that interacts with the Revit API is contained within the node itself.
So, for those of you want to leverage the Revit API but don’t know how to write code, you can now create extremely powerful scripts simply by wiring up nodes, or what I like to call “connecting the dots”. Stay tuned for part two of this series, where I’ll show you how to leverage the Revit API using Dynamo.
The best advice I can give to coders who are looking to break into developing using the Revit API is to start by building macros. Developing macros in Revit is often overlooked; I’m assuming because they are open source (i.e., all of the source code is exposed) or perhaps developers simply don’t know that they exist as an alternative to developing an official Revit add-in. Put simply, a macro is an alternative to building a Revit add-in with some major advantages, particularly while learning the Revit API.
One of the major advantages of using macros for learning the Revit API is that you can compile and run code “on the fly” without needing to build a Revit add-in. In contrast, building a Revit add-in would require you to close your Revit application in order for Revit to overwrite the .addin file to the add-ins directory every single time you test your add-in. This means testing can be excruciating, especially during testing.
Revit has a built-in macro manager which provides an IDE, Sharp Develop. Admittedly, it’s not the best IDE out there, but it gets the job done. The macro manager also allows you to manage modules at the application or project level, meaning you have the ability to either save macros in a particular Revit model (making it available to anyone who opens it) or save macros to your local machine (making it available to any model).
For both “noders” and coders: Dive In!
For all of you developers out there, I’m sure you’re no stranger to wading through pages and pages of documentation. The Revit API is no different. The Revit API will take some time grasp as Revit is a fairly complex piece of software in itself. If reading the documentation included with the Revit API SDK is painful, I recommend you check out RevitApiDocs.com, as it provides a user-friendly, web-based interface to help you through your journey in learning the Revit API.
Really, the only way to learn the Revit API, whether using nodes or writing code, is to learn by doing. Start with something simple like a “hello world” application. Get a TaskDialog to display in Revit. Create a view. Model a wall or pipe. Get started and you’ll never look back.
To learn how to use Dynamo to tap into the Revit API, look for part two of this series coming next week.
Phone: 415 915 2123
Knowledge Center: help.unifilabs.com
Join us on social media.
Copyright © 2023 by UNIFI. All rights reserved.