Problems with PyCharm as an External Code Editor

Hi guys,

I recently started using PyCharm as my external code editor and successfully set up all the necessary libraries. However, I’m encountering some issues with the autocomplete feature.

In this simple example I created a Brep using the CreateFromLoft method, which outputs a Brep array (Brep[]). When I attempt to extract the first Brep from this array and convert it into a surface, PyCharm does not recognize its properties and fails to provide autocomplete suggestions.

I’ve also tried converting the Brep array into a list and extracting the first item, but still, the autocomplete doesn’t work.

Does anyone have any suggestions on how to resolve this issue, or am I doing something wrong?

PyCharm does not know what RhinoCommon types are. For example your list contains Rhino.Geomery.Brep but PyCharm does not have a way of knowing the type members so it can autocomplete for you.

The way this is usually done is through “stub” files (.pyi file extension):

See here for how to use stubs in pycharm

If you are using Rhino 7, you can use this python package that contains stubs for RhinoCommon 7:

If you are using Rhino 8, launch Rhino and run the ScriptEditor command to open the editor. Python 3 inside of Rhino will start creating stub files and will place them under:

%HOMEPATH%\.rhinocode\py39-rh8\site-stubs

You can point PyCharm to this directory

3 Likes

Thanks!
Is this same with VSCode? Or is there a guide how to use VS Code to code GhPython(Cpython) in Rhino8?

1 Like

Yes you can use the stub files with any python editor

Hello, how can I install the stub files for rhino 8? I don’t know why but before I have it when I uploaded them on VS code the folder on this path .rhinocode\py39-rh8\site-stubs became empty. Thank you

Either use this package:

or run ScriptEditor in Rhino to generate the stubs under site-stubs

1 Like