IronPython Autocomplete for RevitAPI and other .Net Assemblies

Myself  and a few other python developers have been hoping to find a way to get python autocomplete working for quite some time. Mostapha first came up with a solution but I was not able to get his solution to work, and as he noted himself, it was “a hack and is not meant to be used by so many people”. His contribution made me realize there were others interested in getting ironpython-autocomplete to work, and this step forward motivated me to keep looking.

After trying a few other approaches , including modifying the Rhino-Python package for Atom editor, I ran into this project, started by Gary Edwards (Thanks for sharing Ehsan !)

The project used Generator3.py, a tool developed by the PyCharm community to make python autocomplete work for IronPython within PyCharm. The library works by inspecting the DLLs using IronPython, and creating stub packages that reflect the same structure. Those stubs can then be accessed by CPython + Jedi to generate the autocomplete suggestions.

It seemed to me this was the best approach, so IronPython-Stubs was born.

The project builds on what Gary started but automates the discovery of all namespaces using recursive calls inside each DLL, making it more scalable. It also optimizes stubs by removing unnecessary characters and also breaking down large namespaces into smaller modules, making it easier for Jedi to digest.

There are still some issues to resolve, for example, many of the Revit API constructor calls are not showing the correct arguments, but I think overtime we will be able to improve it.

More info on the project here:
github.com/gtalarico/ironpython-stubs

autocomplete-demo

Leave a Reply