Skip to content
February 25, 2019 / stevebaer

Autocomplete and Type Hints with Python Scripts for Rhino/Grasshopper

Stubbing out RhinoCommon and Grasshopper Assemblies for Python

This article is specific to the PyCharm python editor. If you figure out how to get the same results with a different editor, please let me know and I’ll update this blog post.

Recent versions of PyCharm support python stub files. Stub files provide information about the classes and methods available in a module along with parameter and return types without actual implementations. This is great news for Rhino and Grasshopper scripting as those module implementations are written in .NET and are something that typical python editors don’t know how to work with.

I wrote a simple application that chews through .NET assemblies and generates python stub files. You can find this project at The repository also contains the resulting stub packages for RhinoCommon.dll, Grasshopper.dll, GH_Util.dll, and GH_IO.dll. This application is not Rhino specific so you should be able to use it for other .NET assemblies that you want to “stub out” for python.

Now the fun part

  1. Start PyCharm and create a new “pure python” project
  2. Go the the settings for the project
    • (Windows) File menu -> Settings…
    • (Mac) PyCharm menu -> Preferences…
  3. Go to the Project Interpreter settings as shown belowpycharm_settings.PNG
  4. Click on the plus (+) button. In the “Available Packages” dialog search for and install the Rhino-stubs package. This will install the Rhino stubs as well as all of the Grasshopper stubsrhino_stubs_pypi.PNG
  5. Create a new python file and import a module like Rhino.Geometry. That’s it! Enjoy autocomplete for all of RhinoCommon and Grasshopper while editing your scriptpycharm_autocomplete.PNG

NOTE: This works for PyCharm on both Windows and Mac. The above screenshot was from Windows. Here’s a screenshot from Mac showing autocomplete:Screen Shot 2019-02-22 at 3.26.08 PM.png


Leave a Comment
  1. Vu / Sep 16 2021 7:34 am

    does it only work with python 2.7 ? can the interpreter be python 3.7?

    • stevebaer / Sep 27 2021 10:01 pm

      The stubs should allow for autocomplete under both python 2 and 3, but note that as for Rhino 7 we are still using IronPython 2.7 to perform the actual interpretation and execution of scripts.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: