Rhino 8 Feature: RhinoCode (CPython, CSharp)

  1. Another item of interest to me: I would like to change the font on the Rhino Code Editor window. The existing font is washed out; there are other fonts which are better like Consolas.

  2. Also on my laptop, the editor window overruns the bottom of the Rhino window so I cannot see the error information put at the bottom of the editor window.

  3. I managed to save a Python 3.9 file but I cannot open it because the editor only looks for files with Python 3 type extension whereas the save created a plain old text extension.

  4. The editor randomly mangles a few lines of code from time to time. I think it may have something to do with its rapid command completion scanning. The completion scanning often times prevents smooth typing with the displayed text lagging many characters behind the typing. There needs to be an option for turning off completion scanning.


1 Like

Ansys Script editor have a nice feature to record commands and replay them.
If that possible in RhinoCode will be very useful to everyone who don’t know anything in scripting.


This looks like a great way to learn things.


Under the hood it is SpaceClaim, which from time to time someone references as nice example of some functionality (for example solid editing or parallel brep faceting/meshing). This editor in SC also allows for creation of parametric parts.

1 Like


Can numpy be used with Rhino Code for Python scripts? In my Python 3.9 script I tried:

import numpy

but this fails.

When I first setup Rhino 8 WIP with Python, I was asked it I wanted Python packages installed and I replied yes. Do these packages not include numpy?

Should I try to use Conga or PIP to install numpy now?


Did you include a line

# r: numpy

before you do

import numpy


Creating a new py3 example file has this at the top:

This project is work-in-progress and still in its infancy

- Reference to RhinoCommmon.dll is added by default

- You can specify your script requirements like:

    # r: <package-specifier> [, <package-specifier>]
    # requirements: <package-specifier> [, <package-specifier>]

    For example this line will ask the runtime to install
    the listed packages before running the script:

    # requirements: pytoml, keras

    You can install specific versions of a package
    using pip-like package specifiers:

    # r: pytoml==0.10.2, keras>=2.6.0

@stevebaer ,

I have been working on getting my 2000+ line IronPython with C++ DLL working in Rhino 8 with Rhino Code Python 3.9 code. I only had to make a handful of changes to get it to run and import a pointcloud. But there is one line in Python that that does not work; the line where it tries to get the Rhino object for the pointcloud using its RunTimeSerialNumber = cpc_serial_number.value which is a C-types uint32 variable passed back from the C++ code. This works fine in Rhino 7 IronPython. Below I have added a print of the cpc_serial_number.value to show that it exists.

from scriptcontext import doc
...... calls C++ DLL here which returns the RunTimeSerialNumber
...... of the point cloud created in the C++ code.
pcObj = doc.Objects.Find(cpc_serial_number.value)

Result of running script with above lines:

192687 # This is the RunTimeSerialNumber of the cloud. It looks good.
TypeError : No method matches given arguments for Find: (<class ‘int’>)
File “C:\Users\Terry\AppData\Roaming\McNeel\Rhinoceros\8.0\scripts\ImportCloudWalls”, line 1959, in
File “C:\Users\Terry\AppData\Roaming\McNeel\Rhinoceros\8.0\scripts\ImportCloudWalls”, line 918, in ImportXYZRGB_DLL
pcObj = doc.Objects.Find(cpc_serial_number.value)
at Python.Runtime.Runtime.CheckExceptionOccurred()
at Python.Runtime.PyScope.Execute(PyObject script, PyDict locals)
at Python.Runtime.RhinoCPythonEngine.RunScope(String scopeName, String pythonFile, Boolean tempFile, Boolean useCache)

The error message says Find has the wrong argument type. Has the Find function changed in Python 3.9 vs IronPython 2.7? How can I get this to work?


We are using PythonNet for interop between CPython and the RhinoCommon .NET library which has some subtle differences from IronPython that we are working on fixing. There are two overloads to the Find function in RhinoCommon and I bet PythonNet is having trouble determining which version of the Find function to use.

There is an equivalent function in RhinoCommon that essentially does the same thing and has been around since Rhino 6.

import Rhino
pcObj = Rhino.DocObjects.RhinoObject.FromRuntimeSerialNumber(cpc_serial_number.value)

(edit) we do hope to fix the situation that you are seeing, I’m trying to provide a work around for now.

1 Like

nice feature. This will be the argument for me to install the WIP.
But - any chance to check if the created scripts are compatible with V7 (or even V6 ) ? (highlight stuff that changed / got added in WIP / V8Beta ) ?

Our goal is to have scripts compatible with previous Rhino releases as long as you are using python 3 syntax. Functions that don’t work like what Terry ran into are bugs that we would like to fix and should not be considered a permanent break.

1 Like

I followed your recommendation and now the Python script is not crashing. My next step will be to try using numpy functions in my script.

Thanks for the quick help.


1 Like


Perfect help. Now it is working using your alternative.


1 Like


I am having trouble with the Rhino 8 WIP/Rhino Code environment. While just editing my script, my computer has hung up a couple of times. I had to power it off and back on to recover. No crash report was generated by Rhino 8. Not sure how to trouble shoot this. Perhaps you are seeing this also? It seems to be caused by using the Rhino Code Editor.

The exact same script runs on Rhino 7 without a problem. I do have to change 1 line to make it work in IronPython. I use the first line below in Rhino 7 and the second line in Rhino 8.

#csep = c_char(sep)|
csep = c_char(bytes(sep, encoding='utf-8'))

But no other changes.

The editor is not yet ready for productive work as it is missing some key functions: save/open files, search & replace, changing font for better readability: WIP on left, Rhino 7 with Consolas 12 on right.

When do you think the editor will get these upgrades? Perhaps in the next month?

It is already exciting to try out this new environment. With a little more work on the editor it will be fun.


That depends on how much we beat up on Ehsan😀 He has taken the lead on this project and has quite a few high priority issues to take care of right away (GH component, debugging, …).

Anything that makes Rhino lock up or crash are also very high priority, so whatever you can do to help Ehsan figure out what is causing this would be greatly appreciated.


Right now my number one frustration with the editor is that you cannot add new lines without causing a runtime error. The problem is that when you hit Enter at the end of a line, the new line is indented with spaces and not a tab. If you back over the lines and hit the tab key, spaces are still entered. I have to copy the ‘space’ from a good previous line and place it over the spaces to get the new line accepted.

My starting point is a Python script created in Rhino 7 with tabs. If I no not add lines the script works in Rhino 8 WIP. Or if I first copy an existing line and then modify it, I can get this to work most of the time. The copy preserves the tab characters embedded in original line. But there seems to be no way to enter new tab characters to indent lines. Only copying the existing tab characters seems to work.

I know in Rhino 7 Python editor there is a tabs-to-spaces option (which I have turned off). The Rhino Code Editor apparently has it turned on resulting in code with mixed tabs and spaces once new lines are added (without my copy/modify procedure). This causes a runtime failure every time.

This is probably easy to fix


1 Like

When making ; Code; Rhino crash(hung) and does not return the lower version codes?

import rhinoscriptsyntax as rs
point1 = rs.GetPoint("First point")
if point1:
point2 = rs.GetPoint("Next point")
if point2:
point3 = rs.GetPoint("Third point")
if point3:
vector12 = rs.VectorUnitize(rs.VectorCreate(point2, point1))
vector23 = rs.VectorUnitize(rs.VectorCreate(point3, point2))
vector13 = rs.VectorUnitize(rs.VectorCreate(point3, point1))
N=rs.GetInteger("Number Of Circle?")

for i in range(1,N+1):

for example :
this run in old editors (python) currently
#P TO P.py (856 Bytes)

I love it :slight_smile: +1 as feature request

Can You please tell me whats am I doing wrong?

You left out a space after the #. It should be:

# r: numpy

Notice there is a green squiggle under #r in your script. It is trying to show you what needs to be fixed.

My script runs with this change. But the version number is reported as 1.21.4 even with your requirements line specifying 1.21.3 included. Is this a problem?


A post was split to a new topic: Creating C++ plugin with VS2022