Resources
Summary
Final Lesson: Most Common Mistakes
Welcome to the final lesson of Module One. I hope that I've helped you to get started with Revit API and pyRevit.
By now you should have:
Setup Revit API Dev Environment
Created custom pyRevit Extension
Learnt how to create Revit Add-ins
And in general - got familiar with Revit API workflow
💡 But don’t forget, there are still many more lessons in the upcoming modules, where you’ll dive deeper into the Revit API.
But in this lesson:
I share the most common mistakes Revit API beginners make. I've started teaching Revit API and pyRevit around three years ago, and I keep hearing about the same mistakes over and over and that's okay. I've also made the same mistakes when I’ve started.
But today I wanna point out those mistakes and most importantly provide you solutions. So, you become aware of these problems and I'll show you how to stop making them.
Mistake #1: Ignoring Python Basics
The first common mistake is ignoring Python basics.
I’m guilty of this myself. When I started creating Revit add-ins, I didn’t have a solid understanding of Python, and my code was absolutely horrible.
Once I became more comfortable with Python, I also got more comfortable with Revit API, because I could focus on one thing at a time.
Solution #1:
To solve this, focus on Python basics until you feel comfortable writing loops, functions and get the general understand of programming logic.
I recommend free courses like:
💡 There are also plenty of courses on YouTube, and I’ve made a video on Python basics for Revit users, which might be helpful.
Mistake #2: Overlooking Revit API Documentation
The second mistake is overlooking Revit API documentation.
When you first open the Revit API documentation, it can be overwhelming. There are thousands of classes, methods, and properties, and it’s hard to know what you need.
But over time, you’ll realize that Revit API is repetitive, and you just need to understand the core classes you’ll use in every script. Like FilteredElementCollector, Transaction, Selection…
And you will learnt the rest when you need it one step at the time. But you need to understand how to read Revit API docs to get the most out of it.
Solution #2:
To make the most of the documentation, I’ve created a deep dive into Revit API documentation for beginners, both on YouTube and on this course platform.
I’ll guide you through the essentials and point you to what you need most.
Mistake #3: Not Reusing Code Early
Another common mistake is not reusing your code early on.
Good programmers code, but great programmers reuse code.
This is the most efficient way to code, and I recommend starting to reuse your code as soon as possible. If you find yourself copying and pasting code from previous scripts, then you should consider creating a pyRevit library of code snippets.
💡Imagine you have a function that you use in nearly all your tools. If you need to update it, instead of manually going through all your scripts, you could just update it in one place, and all your scripts would use the updated version.
Start with small functions, and as you improve, your code will become more reusable.
Solution #3:
Check the Lesson 07 on how to reuse your pyRevit code with lib folder.
Start small, and improve over time one step at the time. It will certainly be worth it.
Mistake #4: Ignoring Code Samples
pyRevit is open source, and so are many additional extensions, including over 200 repositories on GitHub. I also provide a lot of code samples in my:
Why reinvent the wheel, when you use existing code? Use code samples to learn and build your own tools faster. This is like a superpower for beginners, so don’t hesitate to reuse existing code examples.
Solution #4
Remember that you can hold ALT + Click on any pyRevit button to open its source folder, where you will find a python code. It also works on all additional extensions like EF-Tools.
Also you can check GitHub by searching for pyRevit.
Try to either learn something or find snippets that you might use one day and steal them.
Mistake #5: Not Backing Up Your Code
Not backing up your code is another mistake many make.
I've just covered how to do this earlier in the course in Lesson 08, but many of you might have postponed 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 we start regretting for not backing up earlier. I know that many of you have been there and so was I. And it's always because of some stupid mistake.
Don’t wait until you lose your work to start backing up.
Solution #5:
Once you've started your pyRevit extension, find a workflow on how you will back up your 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.
And don't get afraid of Git, you can start with GitHub Desktop, which is very user-friendly client for that. You can rewatch the lesson 8 to learn more about that.
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 Revit API.
There are some new classes, method properties, but also Autodesk can remove different classes and methods from the 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 Revit year and execute correct code for different Revit versions. Here is the code snippet to help you:
I also have a video about it, but it's only inside of my course. I will leave a free copy for you here, but please keep it a secret between us. Link
Mistake #7: Not Handling 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'll get afraid of that and stop clicking the button, thinking that they might harm the project somehow.
Solution #7:
So please, as a bare minimum, start using try and accept 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 developer to fix it".
This will encourage them to share the message and oftentimes, it's actually quite easy to fix your errors once you know about them.
Mistake #8: Forgetting Revit API Uses Feet as Internal Units
Revit API uses feet as internal units, so whenever you read or write values, remember to use feet internally.
💡 I once tried to solve an issue with coordinates when my units didn’t match, because I’d forgotten to convert meters to feet… So, when I was printing the results I was comparing apples to oranges and good luck debugging that.
Solution #8:
Remember that you have to work with feet in Revit API
Here is the code snippet on how to convert units From and To internal, and it's not complicated.
But in general, when numbers don't make sense, check what units do you use and oftentimes this will solve your issue.
Mistake #9: Share Your Mistakes!
Now it’s your turn!
What common mistake have you made with Revit API?
Share it in the comments or in our community. As you've seen with the previous mistakes, I try to produce content and address common concerns and make it easier for you to Learn Revit API.
So please, write down your number one challenge or mistake that you make with Revit API that you want me to help you solve.
🙌 This is a win-win-win for me, you and the community.
Conclusion
That’s it for the grand finale of Module One in the Learn Revit API course.
I’ve provided you a lot resources and tutorials to help you get started and I hope that you've learnt a lot. And I’d appreciate it if you could leave a testimonial and share your experience. It's very quick.
Your feedback means a lot to me and it can motivate others to try it out as well.
HomeWork
Share your number one challenge or mistake that you make with Revit API in the community.
And please Leave a Testimonial about your experience with the module 01 of Learn Revit API Course.
⌨️ Happy Coding!