◼️BLACK FRIDAY DEAL 20% OFF. Ends in:
Jul 17, 2024
How to create Revit API Stubs for Autocomplete with pyRevit
Download Revit API Stubs 20-24 and learn how to create your own stubs with pyRevit.
Download Revit API Stubs
What is Revit API Stubs?
Revit API stubs are simplified representation of the Revit API. Stubs can be used to reference in the IDE(code-editor), so we can get autocomplete suggestions when we code and reference doc strings. This is an essential step for any Revit API developer both beginners and advanced.
How to create Revit API Stubs for other Revit API versions?
It's very common to keep older Revit versions on older projects to avoid any issues. And because of that sometimes people ask me for older Revit API stubs. But instead of that I want to show you how to create these stubs yourself.
As they say, teach a man to fish and he will never go hungry.
For that I would recommend you to watch the video on the top, but I will also write it out in case you prefer written format.
pyRevit Dev Tools
First of all we need to activate pyRevit Dev tools to access a tool that can generate stubs.
Go to pyRevit -> Extensions -> Enable pyRevit DevTools
Once you've enabled this extension you will see pyRevitDevTools tab in Revit.
Generate Revit API Stubs
Go to pyRevitDevTools tab, and look for Generate API Stubs button. This will be able to generate stubs for your current Revit version. Here is how the button looks like:
Once you click on it you will have to select an empty folder where there Revit API stubs will be generated.
And after that you've created Revit API stubs, however we are not done yet. It will not work until you make a little fix.
Fix Revit API Stubs
When pyRevit has generated the stubs it has missed a few __init__.pyi
files.
These files are used to mark a folder structure as python package or stubs so it can read all the nested folders. We don't need to write anything in the __init__.pyi
file
💡Make sure you have __init__.pyi
file in every nested folder so it works.
Setup Revit API Autocomplete in pyCharm / VS Code
Once you have the right Revit API stubs, you can use them in pyCharm or VS Code or any other IDE of your choice.
In case you need help, I've already created tutorials for pyCharm and VS Code and you can watch them here:
Join Newsletter
📩 You will be added to Revit API Newsletter
Join Us!
which is already read by 7400+ people!
Ready to become Revit Hero for your office? Learn Revit API!
Join this comprehensive course that will guide you step by step on how to create your dream tools for Revit that save time.