Pyrevit Autocomplete

Hi everyone,

I was wondering if someone can please help me to understand why my PyRevit autocomplete is only working half way. Is there something else I need to install or a path that I need to change somewhere that I am not seeing?

To me it looks OK.
The autocomplete is imperfect as it requires the code editor to ‘scan’ and retain the whole pyrevit lib / Revit API / … It usually does not go down the substructure that well. What I mean is, when you call revit. the first level does show you the completion options, but the next sub levels are not always showing. At least not in VSCode.

Maybe someone else has better answers/tricks/explaination

1 Like

My experience is that autocomplete is fine until you start using code from the underlying C# API’s. The IDE/code editor can’t access the compiled code, whether that be pyrevits runtime or the Revit API.

I usually use the Revit API directly instead of using pyrevit, so I don’t have many issues. But from my experience pyrevit does not have extensive type annotations based on the standards set forth by PEP 484 in the python 3.5 update: PEP 484 – Type Hints | This PEP lays out standards for type annotations for new and old versions of python which enhances or enables autocompletion and type hinting across various types of IDE/code editors.

The only thing you could do to remedy this problem is create python stubs using the stub builder included in pyrevit, or if that doesn’t work try the ironpython-stubs project GitHub - gtalarico/ironpython-stubs: Autocomplete stubs for common IronPython/.NET libraries to generate stubs for the various .net APIs that Revit and pyrevit use. However, even with these stubs you may have to manually add the type annotations to ensure proper autocompletion.

A more permanent solution would probably require type annotations to be added into pyrevit, and for Revit API and .net framework stubs to be included in the pyrevit installation for proper support of autocompletion and type hinting.

I mostly use PyCharm when I’m editing my python scripts, so my experience may differ from yours. However, even in VSCode the stubs I have generated still provide autocompletion when I’m using VSCode.

1 Like