Setting up PyRevit in VS Code

Hi everyone. I am very new to pyrevit and I have what is probably a silly question. I managed to get buttons and tabs added in revit itself, but when I try to use the Autodesk.Revit.DB import, I get this error:

Import Autodesk.Revit.DB could not be resolved Pylance.

I am using VSCode. From some of the other subs, I think it is related to the interpreter, but I am not sure.

Thanks!

Check YouTube for Erik frits video on generating API stubs. In my experience pycharm is better than vs code, but still not ideal and I think it only works with Autodesk dll and can’t load pyrevit modules. He has videos showing how to set up in both

Here is pycharm video. Vs code should be easy to locate from there.

1 Like

Hello @Mui_Oper,

From description of your problem I’m assuming that you are trying to launch script within vscode. Unfortunately such approach is not supported by pyRevit. To run your code you should just save your scipt.py file and run it simply by clicking correlated button in your custom tab.

I did do that, but I get errors in revit, so I was thinking I had some issue. Do you need to have python installed to use pyrevit?

No.
Everything said or pointed above is right.

1 Like

@Mui_Oper, I’d recommend you to start with getting familiar with this topic:

It should be helpful to make your start (mostly) painless :smiley:

1 Like