Rhino 8 Feature: ScriptEditor (CPython, CSharp)

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 ) ?

1 Like

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.

2 Likes

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.

Regards,
Terry.

1 Like

Steve,

Perfect help. Now it is working using your alternative.

Regards,
Terry.

1 Like

Steve,

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.

Regards,
Terry.

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.

@eirannejad,

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

Regards,
Terry.

1 Like

When making ; Code; Rhino crash(hung) and does not return the lower version codes?
![hang|524x500]

import rhinoscriptsyntax as rs
point1 = rs.GetPoint("First point")
if point1:
    rs.AddPoint(point1)
point2 = rs.GetPoint("Next point")
if point2:
    rs.AddPoint(point2)
point3 = rs.GetPoint("Third point")
if point3:
    rs.AddPoint(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):
    rs.AddCircle(rs.CopyObject(point1,vector12*(i)),i)
    rs.AddCircle(rs.CopyObject(point2,vector12*(-i)),i)
    
    rs.AddCircle(rs.CopyObject(point2,vector23*(i)),i)
    rs.AddCircle(rs.CopyObject(point3,vector23*(-i)),i)
    
    rs.AddCircle(rs.CopyObject(point1,vector13*(i)),i)
    rs.AddCircle(rs.CopyObject(point3,vector13*(-i)),i)

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?

Regards,
Terry.

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

Nope :frowning:


The other requirement is that when you first install Rhino 8 and a question appears about whether you want to install Python packages you have to respond yes. Do you remember doing this?

Thanks Terry, solution found here

Believe me, this tambourine method never fails.

Nice to see that reference for explicitly installing numpy.

Again in my case it was unnecessary as I chose the load Python packages option when installing Rhino 8. It took a while to do this step so there may be other packages already that are ready on my system but will require a separate explicit install on your system.

Have you tried re-installing Rhino 8 to see if the Install Python packages question comes up?

1 Like

@monkelisha Would you mind after running the script and seeing the missing numpy error, open RhinoCode log window from Tools menu and share the full logs. I’d like to see where and why numpy install is failing

@Rh-3d-p Does this crash when you run the script or when you open it?

It’s called WIP for a reason :sweat_smile: So far I have spent most of my time on this project getting cpython and roslyn runtimes to work consistently on intel-windows, intel-mac, and arm64-mac. Everything about this project is work-in-progress.

That said, I really appreciate your feedback and will incorporate these into the “Preferences” window (currently showing a WIP message) to have more control over the editor. All updates to the project will be posted on this thread.

Oh btw, python has black as formatter. If you right click on the script and hit Format it should be able to make the space/tabs consistent as a workaround for now