Last Chance To Claim LIFETIME ACCESS. [~30 Seats left]

Last Chance To Claim LIFETIME ACCESS.

15k+ already joined

Get Full Access

Next Lesson is Coming Soon!

Lesson 10: Avoid These 9 Most Common Mistakes Revit API Beginners Make

Summary

The Most Common Mistakes

I've been teaching the Revit API in Revit for around three years now, and I keep hearing about the same mistakes over and over.

And that's okay—I made the same mistakes when I started.

But today, I want to point out those mistakes and provide you solutions so you:

  • Become aware of these mistakes

  • Get Solutions to avoid making them

Let's dive straight into it.

Mistake #1 - Ignoring Python Basics

I'm guilty of this myself. I started creating Revit add-ins without a solid understanding of Python, and my code was absolutely horrible.

But once I got more comfortable with Python, I also got more comfortable with the Revit API, as I could focus on one thing at a time.

Many people in my community have pointed out the same, and they instantly noticed the difference once they spent some time on Python basics and then came back to continue their Revit API journey.

Solution #1 - Learn Python Basics

To solve this issue, you have to focus on Python basics until you feel comfortable making loops, writing functions, and just focusing on the basics first.

I can recommend free courses on edX.org like:

Also, there are plenty of courses on YouTube, and I also made a video called Python Basics for Revit Users.

Mistake #2 - Overlooking Revit API Documentation

When you open Revit API documentation for the first time, it's overwhelming, to say the least. You can see thousands of classes, methods, and properties, and you don't even know what you need.

But over time, you realize that the Revit API is repetitive, and you just need to understand the core classes that you will use in every script, like:

  • FilteredElementCollector,

  • Transaction,

  • Selection,

  • and so on.



The rest you can pick up whenever you actually need it.

Solution #2 - Understand Revit API Documentation

You need to understand how to read Revit API documentation to get the most out of it. I've made a deep dive into Revit API documentation for beginners both on YouTube and my course platform to explain everything inside the documentation and point you to what you need the most. All the links are going to be in the description under the video.

Mistake #3 - Not Reusing Your Code Early

As you've heard already, good programmers code, but great programmers reuse code. And it's because this is the most efficient way to code. I want to recommend you start reusing your code as soon as possible.

I know that it's great to quickly copy-paste your code from previous scripts, but if you do this too often, you definitely need to consider using the pyRevit Library.

Solution #3 - Start Reusing Code ASAP

Imagine that you have a function that you use in nearly all your tools. It works great, but then you realize that you have to update it. You could go through all your scripts and manually update them one by one, or you could just go to your library folder, change it in one place, and then all your scripts that use this function will use the updated version.

This will also teach you how to make your code more reusable because you'll have to think about how to combine a lot of functionality into a single function. But if you're a beginner, just start with small functions and slowly improve them. You don't have to create complex functions right away—just start small and slowly increase complexity.

If you learn how to reuse your code in pyRevit, I've already made a video in this free first module of this course where I explain step by step how to do that.

Mistake #4 - Ignoring Code Samples

pyRevit is open source, and so are all additional extensions, including 200 repositories on GitHub. I provide a lot of snippets in my eBooks, pyRevit Starter Kit, on my website, in the blog newsletter, and in my Python snippet sections. So oftentimes, you can find a lot of code that you can learn from and "steal like an artist" to reuse in your own tools.

Solution #4 - Steal Like an Artist

So why do you keep reinventing the wheel? It's much quicker to figure out how existing snippets work instead of trying to rewrite them from scratch. That's like a superpower for all beginners.

Start reusing existing code examples first. Remember that you can hold Alt and click on any pyRevit tool—including all additional extensions like EF Tools—have a look inside, try to either learn something or find snippets that you might use one day and steal them.

Mistake #5 - Not Backing Up Your Code

I've just covered how to do that a few lessons before this one, but probably many of you decided to postpone it for some other day and haven't done it anyway. We all know that we should do this, but we all ignore the backups until one day we lose a chunk of data and start regretting not backing up earlier.

I know that many of you have been there, and so was I. It's always because of some stupid mistake—you just try to rush something, you delete without thinking it through, and so on, and then your files are gone.

Solution #5

Once you've started your pyRevit extension, find a workflow on how you will back up these files. You can use Dropbox, Google Drive to sync your folders to begin with, but GitHub is by far the best solution for backing up code. You can get started with GitHub Desktop as it provides the most user-friendly experience. You don't even need to know much about Git.

You can rewatch this video from Module One on How to Back Up and Share Your pyRevit Code with the Team to learn more about this.

Mistake #6 - Ignoring Other Revit Versions

Every year we get a new version of Revit that comes with all the new features, and so does the Revit API. There are some new classes, methods, properties, but also Autodesk can remove different classes and methods from newer versions. So you should be aware of that.

It's very common to ignore other Revit versions, especially in the beginning, but once your office starts using another Revit version, some tools might not work correctly because of obsolete Revit API code or some other changes. And it's never a good idea to fix stuff in production.

Solution #6

Make sure that you check your tools on multiple Revit versions and fix the code accordingly when needed. Once you find an issue across different versions, you can check the Revit year with the app.VersionNumber and execute the correct code for different Revit versions.

I only have a video about this inside my course, but I've made a free copy for you so you can watch it for free—just don't tell anyone about this.

Mistake #7 - Not Handling Your Errors

It's okay to code dirty during development, but ideally, in the end, you need some form of error handling. You don't want users in your office to click on a button and then see a huge wall of red text. They will get afraid of that and stop clicking the button completely, thinking that they might harm the model somehow.

Solution #7

Please, as a bare minimum, start using try and except statements to catch your errors and suppress the error messages. You can also create an alert popup saying, "Don't panic, but something went wrong. Ask the developer to fix it," because oftentimes it's actually quite easy to fix your errors once you know about them, but users don't like to share this.

To avoid this, try to use try and except statements to catch your errors, alert your users without scaring them, test your tools with various scenarios, and test multiple Revit versions. This is going to help you a lot in creating your tools.

Mistake #8 - Revit API uses Feet internally

Coming Soon…

Solution #8 - Be careful with units you use

You just have to remember that we have to work with feet in the Revit API, and oftentimes you need to convert from feet to meters before printing them so you can see the right values in the console.

Here's a code snippet to convert units:

pythonCopy codeimport math from Autodesk.Revit.DB import UnitUtils, DisplayUnitType # Convert from internal units (feet) to meters meters = UnitUtils.ConvertFromInternalUnits(value_in_feet, DisplayUnitType.DUT_METERS) # Convert from meters to internal units (feet) feet = UnitUtils.ConvertToInternalUnits(value_in_meters, DisplayUnitType.DUT_METERS)

In general, when numbers don't make sense, check what units you are using, and oftentimes this will solve your issue.

import math
from Autodesk.Revit.DB import UnitUtils, DisplayUnitType

# Convert from internal units (feet) to meters
meters = UnitUtils.ConvertFromInternalUnits(value_in_feet, DisplayUnitType.DUT_METERS)

# Convert from meters to internal units (feet)
feet = UnitUtils.ConvertToInternalUnits(value_in_meters, DisplayUnitType.DUT_METERS)

Mistake #9 - Share Your Mistake

Now it's your turn to share a common mistake that you make in the Revit API. Share your mistake in the comments or in the community. There are certainly other mistakes people make that I haven't mentioned in this post, and I want to hear more about them.

Solution #9

As you've seen with the previous mistakes, I try to produce content and address common concerns to make it easier for you to learn the Revit API. So please write down your number one challenge or mistake that you make with the Revit API that you want me to help you solve. This is a win-win-win for me, you, and the community as a whole, as I'm the guy who loves hearing more about Revit API issues so I can help you solve them.

What's Next?

And that's it for the grand finale of Module One of the Learn Revit API course. I've given you eBooks, the pyRevit Starter Kit, and a ton of high-quality tutorials to help you get started. I would appreciate it if you could leave me a testimonial about your experience. Just share with me what helped you the most and if I managed to exceed any of your expectations.

If you were to recommend this to one of your friends, what would you tell them, and how did it specifically help you? You can go to my website kudos.learnrevitapi.com or check the link in the description. That would truly mean a lot to me and prove that all I've done here is not fluff but actually high-quality stuff for any Revit API beginner.

Final Secret

And if you want to learn more, you're more than welcome to check my Learn Revit API course. This is the most comprehensive training for the Revit API, and I worked really hard on adding additional courses, modules, and bonus content to the course, alongside support in the community—which many people mentioned is already worth the price of the course.

So I hope to see you inside my course one day, or you can keep watching my free content on YouTube and keep reading my newsletter until one day you decide to get more.

HomeWork

⌨️ Happy Coding!

🙋‍♂️ See you in the next lesson.
- EF

🙋‍♂️ See you in the next lesson.
- EF

Questions:

Q

Q

🔒 Online Discord Chats are available only to Course members.

Join Here.

🔒 Online Discord Chats are available only to Course members.

Join Here.

🔒 Online Discord Chats are available only to Course members.

Join Here.