Rhino 8 Feature: RhinoCode (CPython, CSharp)

Interesting - error occurred during installation. This doesn’t show up unless you close and reopen the editor.

Also made a quick video showing things (pardon the garbage gate setting on the audio): Rhino 8 WIP Python Not Installing - 2021-11-16 - YouTube

Would you mind opening the logs from Tools menu and DM me all the text in there?

1 Like

For those playing at home, I’ve sent @eirannejad the log output, but it looks like things might be choking on the fact that there’s a space in the directory path for my home directory. Just waiting to hear if that’s a correct interpretation or I’m horribly wrong.

Yup. Home directory is C:\Users\Jason Gillman\... that has a space in the middle :face_with_hand_over_mouth: I will fix the code to wrap the paths so spaces aren’t an issue.
Logges as RH-66372

Update: Fixed and pushed but I’m not sure if it is going to show up in today’s release. If not it’s gonna be in next weeks’

1 Like

Thanks for the quick work. So WIP releases go out on Tuesdays then?

1 Like

I’m pretty sure. Your Rhino WIP will notify you of releases :smiley:

Well, glad I could help get the issue identified and resolved earlier rather than later!

1 Like

3 posts were split to a new topic: Lisp Programming Language


  1. Using the Format command on a Python file in the Rhino Code Editor has unexpected consequences. It turned:

ignore_colors = False # Set to True to minimize memory usage.


ignore_colors = (
…False # Set to True to minimize memory usage.

The python script still executes but it is no longer tidy for reading.
It seems as though Format is applying what makes sense for C# type formatting to the Python script. What I really want is my own formatting with all tabs and no spaces at the start of lines like what I could do in Rhino 7 Python Editor.

  1. The Format command turns all my tabs into spaces so that there are no more errors when I add lines. Well mostly no errors. I find that the code completion monitoring can cause typing results not to show on the screen for over 5 sec and then it sometimes does not ever restart and I have to kill and restart the Rhino Code Editor. This happened when I was typing: print(‘Select file’) → it hung up before I could finish typing the rest of the ‘Select file’ string. Is there a way to turn off command completion? I mostly do not need it and currently it makes editing so painful that I use the old Rhino 7 Python Editor instead. Then I copy and paste into the Rhino Code Editor for execution in Rhino 8 WIP.

  2. The message area at the bottom is now scrollable which is very good.

  3. The Rhino Code Editor now almost fits in the Rhino Window when it first comes up. It is still about 10% too tall. Again this only occurs on the native laptop screen not when I am using my external 42" Display.

So nice progress. Thanks for your work on the Rhino Code Editor.


1 Like
  1. It is not. This is how black formats python by default. We will expose formatting options in the language options later to configure this
  2. Work in progress
  3. Great
  4. Work in progress

Release Notes (8.0.21321.4306)

  • Closed RH-66280. RhinoCode now has language options. Diagnostics can be toggled through this options window for each language independently. More language-specific options to be added to this window later. See “Toggle Diagnostics” in Edit menu as well

I’ll update the language editor in the future so it has a better ui. Each option really has 3 states
Default: whatever the default setting is in editor
Checked: This will be stored in config file as user preference
UnChecked: This will be stored in config file as user preference

  • Editor now focuses on diagnostic lines when clicked in the diags panel items
  • Editor now can activate minimap
  • CPython runtime now includes header files (necessary for some packages on macOS)
  • CPython runtime directory changed from cpython-X.X/3.X.X format to python3.X-X.X. It’s simpler and shallower now
  • CPython runtime config file is now called config.json and does not include the version anymore. that is reflected in the directory name
  • ~/.rhinocode now includes logs/ for log files. Rhinocode logger will now dump logs and stack trace on dotnet fails with unhandled exception
  • Rhino.Runtime.Code does not reference RhinoCommon anymore. This is to keep the api clean for future
  • CPython now does not install packages every time the script is opened. It checks the script packages against what is already installed in the environment and caches this information during the session
  • Welcome panel now shows a link to release notes
  • Improved RhinoCode server and cli for upcoming vscode integration
  • Editor now support converting indentation types. Closed RH-66341
  • Editor now limits size to screen RH-66355
  • Terminal panel on windows is now scrollable RH-66354
  • Editor now has “Clear Terminal” command
  • Other misc editor GUI cleanups

Reported the config.json write bug here RH-66394


  1. One nice feature in the Rhino 7 Python Editor (and Visual Studio Editor) is that clicking on an error line in the message window at the bottom of the editor jumps to that line in the code. Big time saver. Just want to make sure this is in your sights.

  2. One serious problem I am having in the Rhino Code Editor is that some of my long lines (more than 100 characters) are not editable without becoming mangled (dropped characters). It can look ok on the display but if I Save, Exit Editor, Reopen Editor, then I see the mangled line. I will try to put together a simple test case that shows this.


  1. Already added. See release notes.
  2. Great thank you. I know where the problem are is for this specific issue. This needs cleanup and improvements to be robust. Please DM me any/all the examples you have :pray:

Well, looks like I got things working with PyCharm, so that’s a plus!

1 Like

So it appears that it doesn’t like type hinting.

Here’s the “script”:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

current_doc: Rhino.RhinoDoc = sc.doc

And this is the error it threw:

Obviously not liking the colon used to specify the expected type.

Also doesn’t seem to like the -> for specifying method return types:

def increment_hsv(rgba, inc_amt) -> System.Drawing.Color:
    Increment the Hue degree and return the new System.Drawing.Color object

    :param rgba: The current object
    :param inc_amt: The amount to increase the hue
    temp_hsv = Rhino.Display.ColorHSV(rgba)
    current_hue = temp_hsv.H
    temp_hsv.H = current_hue + inc_amt

    return temp_hsv.ToArgbColor()


Looks like you are running the code with the old IronPython engine. Instead use RhinoCode to run your script.


Ahh, ok, I was under the impression that RunPythonScript used cpython as well.

There is a way to run the code from PyCharm via OS command-line in Rhino, but I forgot how. @eirannejad will tell you the spell to cast, I am sure.


Based on what I’m seeing for the available signatures, I’m guessing it’s not liking default_number

def RealBox(message="", default_number=None, title="", minimum=None, maximum=None):
    """Display a dialog box prompting the user to enter a number
      message (str, optional): a prompt message.
      default_number (number, optional):  a default number.
      title (str, optional):  a dialog box title.
      minimum (number, optional):  a minimum allowable value.
      maximum (number, optional):  a maximum allowable value.
      number: The newly entered number on success
      None: on error
      import rhinoscriptsyntax as rs
      radius = rs.RealBox("Enter a radius value", 5.0 )
      if radius:
          point = (0,0,0)
          rs.AddCircle( point, radius )
    See Also:
    if default_number is None:
        default_number = Rhino.RhinoMath.UnsetValue
    if minimum is None:
        minimum = Rhino.RhinoMath.UnsetValue
    if maximum is None:
        maximum = Rhino.RhinoMath.UnsetValue
    rc, number = Rhino.UI.Dialogs.ShowNumberBox(
        title, message, default_number, minimum, maximum
    if rc:
        return number
def ShowNumberBox(title: str, message: str, number: System.Double, minimum: float, maximum: float) -> typing.Tuple[bool, System.Double]: ...