Lesson Objectives
Learn what is Revit API
Understand API benefits for Revit Automation
Why you don't need to learn all Revit API classes
Recognize that Revit API is repetitive
Are you Ready?
Summary
Welcome to Revit API Module
This will be the most important module for creating your own custom tools for Revit, because you need to know how to use Revit API to interact with Revit with python.
I will take you through the basic steps that all beginners need to learn in order to start creating custom add-ins. But before we begin with coding, let's understand what the hell is Revit API?
What is the Revit API?
API stand for Application Programming Interface(not very descriptive).
In simple terms, it's a set of instructions from Revit developers, to share pieces of functionality so we can create 3rd party add-ins to automate our work or creating custom workflows.
Think of it as a bridge that lets you interact with Revit. Just like you use your mouse and keyboard but with the code. And code is the best leverage you can get on your time.
You write code once and then you can reuse it over and over and save time every single time. And not just you, but also all your team members. Just imagine how much time you can save in the long run.
This is the True Power of Automation.
Benefits of Revit API
In context of Revit, the API allows us to:
Automate repetitive tasks
Create custom tools tailored to your specific workflows
Access and manipulate project data
Minimize human errors in tedious tasks
Seamlessly exchange data with other software
And in general - Automate Revit.
But to do all that, you need to understand Revit API basics.
Revit API Might Seem Intimidating (But Isn’t)
Also keep in mind that Revit API is really huge and you can't remember everything. But luckily, you don't have to.
You just need to learn the basic concepts and you will already be able to create a lot of cool tools. And then you would learn about other classes whenever you need them by understanding how to read the documentation and apply it in your own code.
The most important topics in Revit API include:
Selection
Reading Properties and Methods
Getting and Reading Parameters
Making Changes in Projects
Mastering Getting Elements
Creating Elements
And these basics alone will help you achieve a lot.
Revit API is repetitive
Also, don't worry if you see a Revit API code and you find it too complex or confusing right now. Revit API can look really intimidating but it's also incredibly repetitive, and over time you will realize how much code is being reused over and over.
Let me just show you an example with FilteredElementCollector
class which is used for getting elmenets from the project by using filters such as OfCategory
, OfClass
and others…
You don't need to understand it yet, but just compare these 3 lines of code.
I know it looks like a very long and confusing code right now, but don't worry. It's one of the most easy ones to use. Here is what each line does:
1st line - Get a list of all window instances in the active project
2nd line- Get a list of all door instances in the active project
3rd line - Get a list of all door types in the active project.
Overall you should already see how repetitive these lines of code are. We just need to change very little to get different categories, or filter instances instead of types. And the same applies to many other classes in Revit API.
Revit API code might look intimidating at first, but as you practice, it becomes more intuitive and easier to use. Just give it time and practice and it will start to be more natural.
Encouragement for Beginners
If you feel overwhelmed, remember this: you don’t need to learn everything at once.
Start small, focus on the basics, and build your skills step by step. Focus on creating a lot of little tools to build up your courage and learn more about Revit API and over time you will be ready to tackle bigger problems with Revit API.
Revit API is like a puzzle—every piece you learn makes the whole picture clearer. Over time, repetitive patterns will become more obvious and you start to understand the logic used in Revit API.
What's Next?
Alright, enough talking about Revit API, let's actually get ready for coding with it.
In the next lesson, I will help you set up your battle station and make sure you have everything you need to write Revit API code.
So buckle up—this is just the beginning of your journey to becoming a Revit hacker. By the end of this module, you’ll be creating custom tools and unlocking the full potential of Revit automation.