LearnRevitAPI

Jul 9, 2024

Get The Most from Revit API Docs

Whether you are a beginner or an intermediate Revit API user, you need to understand the documentation to get the most out of it.

There is not way out of it.

💡So, Let's Learn: How To Get The most out of RevitAPI Docs

What Docs to Use?

There are different places we could reference Revit API Docs:

- Offline RevitAPI.chm from Revit API SDK (Not Recommended)
- www.RevitAPIDocs.com <- My preference
- www.APIDocs.co

Revit API Namespaces

First of all you will see a lot of Namespaces in Revit API. Namespace - is like a package for classes, enumeration and other objects.

95% of your imports will come from the Autodesk.Revit.DB Namespace.

However, it's important to keep in mind that often times you might need classes from other places like

Autodesk.Revit.DB.Architecture
Autodesk.Revit.DB.Structure
Autodesk.Revit.DB.Plumbing

and so on...

What do we need in Docs?

While going through Revit API, you will notice there are thousands of classes. But we don’t need all of them! 

We just need to understand a handful of classes, and it will be enough to start creating Revit Add-ins.

Classes

On the class page, you’ll see the class name, its namespace(1), description(2) and Syntax(3). Usually that's generic, but sometimes you might want to read it through.

Also, when you will select any class, it will open up in the sidebar menu. You might see different things inside like members, methods, properties... 

💡 You will notice that in the sidebar menu you will only see things that come directly from the selected class. 

But on the right menu, you will also see all the methods and properties that are inherited from other classes. 

Therefore, you might only see 7 methods on the left and like a 100 on the right.

It will be marked (Inherited from ClassName.)

Remarks

When you Scroll down, you will find Remarks. 
Remarks sections can be very useful for some classes. 

They often contain warnings about certain errors or workflows. Always check remarks when working with new classes. 

Examples

If you’re lucky, you’ll find examples, although they will be in C#. 

But there is nothing to worry about. It's not hard to translate C# to Python and also you can ask ChatGPT for help. It's not always perfect but it gets the job done pretty well.

Understanding Inheritance

Inheritance is a key concept in object-oriented programming. 

For instance, the Wall class inherits properties and methods from the HostObject, which inherits from Element, and so on. 

This means that Wall has not only its own properties and methods but also those inherited from its parent classes. 

Understanding the inheritance will help you understand the relations between different classes and repeating attributes that classes have.

Properties 

Properties and methods are crucial parts of any class.

When looking at properties you will be most interested in the Syntax section. You will learn :

- What Type is being returned
- Can you Read/Write I

For example, the Scale property of a view can be both read and set. To modify properties, you can just assign the value with an equal sign like (view.Scale = 50)

Also, you will encounter properties where the returned value is an Enumeration. It means that there is a list of allowed values that you can get and which can be used to set new values.

Enumerations is like pulldown menus with all available options.

Methods

When you look at the methods, you will also be most interested in the Syntax. This is where you will find out about all necessary arguments, and also their types.

Usually it's self-explanatory, but sometimes you might want to read some details. Then you can scroll down to Parameters section where each argument will be described with a little more details.

Want to learn more?

I would recommend you to watch the YouTube tutorial, if you are interested in this topic. It's much easier to explain when I can point to things in Documentation.

You can see it here: Revit API Docs Tutorial

Join Learn Revit API Course

Learn Revit API step by step so it's not so overwhelming.

You will get access to 50+ lessons which contain not only 15 hours of video content, but also each lesson is written out to help you learn. 

On top of that you will get access to the LearnRevitAPI community.

Join the Course

Enjoyed Newsletter?

Leave a Testimonial Here.

⌨️ Happy Coding!
Erik Frits

Join Newsletter

📩 You will be added to Revit API Newsletter

Join Us!

which is already read by 6700+ people!