Fast-Track pyRevit Systemโ„ข

Table of Contents

No headings found on page

LESSON

05

Quick-Start: VS Code

Time to set up VS Code so it gives you real Revit API and pyRevit autocomplete. You'll install the editor, add the Microsoft Python extension, and create isolated virtual environments for each Revit version (venv-rvt-25 and venv-rvt-26). Then one small package, pyrevit-stubs, unlocks full autocomplete. By the end your editor suggests Revit API classes as you type, and you'll even see how two Revit versions can live side by side.

Written Summary

Time to set up VS Code so it gives you real Revit API and pyRevit autocomplete. You'll install the editor, add the Microsoft Python extension, and create isolated virtual environments for each Revit version (venv-rvt-25 and venv-rvt-26). Then one small package, pyrevit-stubs, unlocks full autocomplete. By the end your editor suggests Revit API classes as you type, and you'll even see how two Revit versions can live side by side.

Download and install VS Code ๐Ÿ› ๏ธ

Let's quickly set up Visual Studio Code so you get Revit API and pyRevit autocomplete, plus AI on top. First, the install:

  1. Search for VS Code and open the official website.

  2. Hit the Download button and let it finish.

  3. Run the installer like any other software: accept the terms, Next, Next, Next... and on the options screen, select all the checkboxes. Then Install and wait.

  4. Click Finish and open VS Code for the first time.

First launch: sign in with GitHub

On the first launch it prompts you to log in with GitHub. You can continue without signing in... but I highly recommend creating a GitHub account. It's free, and you need a place to store your code. Create or authenticate, then come back to the editor.

You'll get a quick intro: pick a team (doesn't matter), and it tells you about an AI agent (doesn't matter either). Now you're on the welcome screen.

Open your .extension project

First thing to do is open the .extension folder you created earlier.

  1. Click Open Folder and find where your extension lives.

  2. Select the folder. If VS Code asks whether you trust the authors, yes, you're trusting yourself here.

  3. In the Explorer on the left you'll now see your full extension structure: all the folders and files. You can even drag scripts around and put them side by side. Lots you can do, but that's not the point right now.

๐Ÿ–ผ๏ธ [IMAGE: screenshot of the VS Code Explorer with the .extension folder open and its folder structure visible.]

Make Python work

Click New File, call it something like test.py, and start typing print. You'll notice... no autocomplete. You might get a grayed-out AI suggestion, but that's different. Plain Python isn't working yet because we still need the Python extension.

  1. VS Code usually pops up "do you want to install the recommended Python extension?". Click yes.

  2. If you don't see that, click the Extensions button, type python, and Install. Make sure it's the one from Microsoft.

  3. It installs a few things (debugger, environments, and so on). Let it all finish.

Now the Python icon appears in the sidebar. Test again: type print and you get auto-suggestions, with little explanations of the function. Your Python works.

print("Hello World")

Don't have Python installed?

If autocomplete still doesn't work, you might not have Python installed. Click the Python icon and check. If there's no version listed:

  1. Go to python.org and open Downloads.

  2. Grab any version that is not a pre-release. 3.14 is totally fine.

๐Ÿ’ก Tip: the exact version doesn't matter. Remember, we never execute Revit API code here, we only write it. So pick whatever.

The real goal: Revit API autocomplete

Our actual goal is pyRevit and Revit API autocomplete. Try typing:

from Autodesk.Revit.DB import *

Nothing gets suggested. You might see a grayed-out AI autocomplete, but if you hit Ctrl+Space there are no real suggestions, because Python doesn't know what this is yet. Let's fix that.

Create virtual environments ๐Ÿ“ฆ

Click the Python icon. You'll see your global packages. What we want is a venv (virtual environment): an isolated box with the Python settings and engine for one project. You can create several and switch between them without messing up your settings. It's perfect for keeping different Revit versions apart.

  1. Click the + next to Virtual Environments.

  2. Choose Custom, then the latest Python version.

  3. Name it venv-rvt-25 (venv = virtual environment, rvt + the Revit version).

  4. Skip package installation for now.

  5. Do it again for the next version: Custom, latest, name it venv-rvt-26, skip packages.

Give it a moment and both environments pop up. You can see which one is active at the top, and switch between 25 and 26 whenever you want. If something bugs out, hit refresh and that usually fixes it.

๐Ÿ–ผ๏ธ [IMAGE: the "one Python, many isolated boxes" diagram. A central Python with wires down into venv-rvt-25 and venv-rvt-26 boxes, each holding its own pyrevit-stubs.]

Install pyrevit-stubs

Now we install one package that gives us all the Revit API and pyRevit autocomplete. This used to be a real hassle, lots of manual setup and constant issues. Now it's super simple.

  1. Start with 25. Click the Create Python Terminal icon. It opens a terminal and activates that environment for you.

  2. Check the prompt so you know which environment is active. Then run:

pip install pyrevit-stubs-25

Let it install, it takes a little bit. Now the same for 26, but pay attention:

  1. If you open a terminal right away you're still in 25. First click venv-rvt-26 to set it as your active environment.

  2. Open a new Python Terminal and confirm the name shows 26.

  3. Run pip install pyrevit-stubs-26.

๐Ÿ’ก Tip: you don't actually need to set this up for every Revit version. One is enough to get going. You can always come back later and add another.

Test your autocomplete

Refresh, pick either environment, and test it. Type:

from Autodesk.Revit.DB import *
walls = FilteredElementCollector(doc)

Hit Ctrl+Space and now you get all the autosuggestions from the Revit API. It's snappier, and as you type you'll get faster, better suggestions. Same with pyRevit:

from pyrevit import forms
forms.alert()

You'll see the doc strings right away: title, sub_message, and so on. So pyRevit autocomplete works too.

๐Ÿ–ผ๏ธ [IMAGE: the Ctrl+Space autocomplete popup showing FilteredElementCollector and other Revit API classes.]

โš ๏ธ Reminder: we use the editor to write our scripts, but we never execute them here. We run them from Revit through pyRevit, because it has its own Python engine connected to the Revit application.

Proof the versions are different

Want to see the two Revit API versions are really different? Revit 2026 has a new class called ViewPosition.

  • On 25, type viewport and Ctrl+Space: you get Viewport, but no ViewPosition.

  • Switch to 26, Ctrl+Space again: now ViewPosition shows up.

That's the API changing between versions. A few classes get added or removed over time. Not a big deal, and I'll show you how to deal with it later.

What's next

That's it, your VS Code is configured for the Revit API and pyRevit. If you hit any issues, drop a comment below the video and I'll try to help. Next lesson we do the exact same thing in Cursor, which will be our main editor. See you there.

LESSON FEEDBACK

Time to set up VS Code so it gives you real Revit API and pyRevit autocomplete. You'll install the editor, add the Microsoft Python extension, and create isolated virtual environments for each Revit version (venv-rvt-25 and venv-rvt-26). Then one small package, pyrevit-stubs, unlocks full autocomplete. By the end your editor suggests Revit API classes as you type, and you'll even see how two Revit versions can live side by side.