PyRevit with Visual Studio?

I’d like to properly debug my pyrevit code using VS, as that offers proper debugging functionality. has anyone figured to set pyrevit up with visual studio?
Would be a huge help!

Hi Mark,

you can add an extra path for pyrevit:

"python.autoComplete.extraPaths": [

    "C:\\Users\\yourusername\\AppData\\Roaming\\pyRevit-Master\\pyrevitlib"]
1 Like

I think this relates to VisualStudio Code, not Visual Studio :slight_smile:

I don’t think he means just adding the pyrevit library to the python path.
I think he means actually debugging using breakpoints, frame inspections, the whole shebang.

As far as I myself know that’s not going to be possible.

2 Likes

@GertjanVDB yup exactly, the answers provided unfortunately don’t help much. It generally feels a bit like the pyrevit project has lost a bit of love from the developers, given the development speed in the last couple months. I switched back to C# now.

You do you man, I can understand where you’re coming from.

Updates have been a bit sparse recently. I suspect partially because of the specific Niche pyrevit operates in. I think there’s a shortage of hands for the scope the tool has acquired.

It’s an open source development tool that hooks into an expensive piece of proprietary software.
Most people developing for revit are most likely also interested in standalone tool development.
I suspect most people developing for pyrevit are people that want to automate boring tasks without a lot of hastle.

But there’s one thing I do feel I should point out about your original question and your conclusion.
I think you’re approaching the python scripting in the same way as you would for a compiled language.
And I don’t think that in that frame python will ever get ahead of something like C#. To debug python code, you will need to go about it in a different way. Log messages are the key here.
You can create a text-log of everything your tool is doing. If there’s errors you get a neat little traceback that tells you where it went wrong. It’s not hte same as using a debugger, but it get’s the job done. I’ve even grown quite accustomed to it.

Python development has some big advantages over C# that I’ll defend any time.

  1. Development and prototyping times are insanely short. Scripts are compiled at runtime, changes are loaded as-you-go, no restarting revit, no re-compiling because of a small spelling mistake.
  2. The syntax of python is fingerlicking good. … to… uh… watch, easy to read, and therefore easy to share
  3. You can do nearly anything a C# plugin can
  4. It’s easier to develop with no costs or licenses in python, than it is in C# (IDE etc)
6 Likes

If you want test your python code immediately, I suggest you use RevitPythonShell. You can run your code line by line