Rhino 8 Feature: ScriptEditor (CPython, CSharp)

For no reason I can think of, it just now worked…

Now it didn’t work

Did a couple more close and reopens, and it is not working unless I delete the Python install and let it run its course again. No idea why it might be failing on the runtime init.

2 Likes

hello.when I write rs.GetObject() on the vscode workplace, no response in rhino windows for me. I do not know whether it is a bug?

Are you running your code from vscode with Run in Rhino command?

yes, I press F1 in vscode and select run in rhinowip, but no response in rhino command area

just rs.getobject and rs.getobjects no response, other api are normal operation

When I try to run the following Rhino command via rhinocode/python3 with WIP 8.0.22340.12305, 2022-12-06:

import Rhino
import rhinoscriptsyntax as rs
rs.Command(‘_About’)

I get the following error:

Info 12/10/2022 11:54:07 PM [RhinoCode] Execute on platform: Rhinocerous 3D @ 8.0.22340 (mcneel.rhino3d.rhino)
Info 12/10/2022 11:54:07 PM [RhinoCode] Execute started
Error 12/10/2022 11:54:07 PM [RhinoCode] Traceback (most recent call last):
File “file:///C:/Users/delf/wip_rhinocode_command_issue.py”, line 3, in
File “C:\Users\delf.rhinocode\python3.9-1.24\site-rhinopython\rhinoscript\application.py”, line 318, in Command
start = Rhino.DocObjects.RhinoObject.NextRuntimeSerialNumber
NameError: name ‘Rhino’ is not defined
Info 12/10/2022 11:54:07 PM [RhinoCode] Execute ended
Info 12/10/2022 11:54:07 PM [RhinoCode] [pyminilsp] INFO - request to diagnose C:\Users\delf.rhinocode\stage\ycyagezz.nzv
Info 12/10/2022 11:54:07 PM [RhinoCode] [pyminilsp] INFO - checks complete

It looks like the Rhino module is not being properly imported for rhinopython’s application.py. Does anyone else have this problem?

Look :eyes: Ironpython 3 is now out !

2 Likes

Why this error? I would like to try c# in RhinoCode.

When I tried to open the RhinoCode editor RhinoWIP immediately crashed. And later I tried GHPython it crashed too. I’m using the latest version(8.0 (8.0.22347.14306)) and macOS 13.0 (22A380).

The error message is below. Might be something to do with a js framework for text editor?
log.txt (122.0 KB)

[ERROR] FATAL UNHANDLED EXCEPTION: System.AggregateException: One or more errors occurred. (Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=1, WKJavaScriptExceptionMessage=ReferenceError: Can't find variable: ed, WKJavaScriptExceptionColumnNumber=3, WKJavaScriptExceptionSourceURL=ed:///EdCoreAssembly/js/dist/index.html, NSLocalizedDescription=A JavaScript exception occurred})

Full error log in linked file.

Thanks. It is fixed and is available in latest WIP build

Hello, this’s a amazing work. How can I use ghenv.Component in RhinoCode? I want to write a scripts like this ExpireSolution in GhPython, but it shows “ghenv not defined”. Looking forward to your reply, Thanks!

from scriptcontext import sticky

thisDoc = ghenv.Component.OnPingDocument()
slider = ghenv.Component.Params.Input[0].Sources[0]

if click_me:
    # reset values to starting position
    sticky['running'] = True
    slider.TickValue = 30 

desired_area = 12
if sticky['running']:
    if area > desired_area or slider.TickValue >= slider.TickCount:
        sticky['running'] = False # break the loop
    else:
        def sln_delegate(doc):
            slider.TickValue +=1 
        thisDoc.ScheduleSolution(1, sln_delegate) # call the delegate function and schedule a solution in 1 millisecond

@tan1 I haven’t added the ghenv module yet. I have logged this here RH-69069

Hi Ehsan, I am so grateful for being able to code in Python3 and being able to install different libraries. For me that’s a 10 year long wish come true, so thank you!

I do have a few wishes for RhinoCode that would speed up my workflow:

  • let RhinoCode print to CommandLine while the script is ran. Right now print(“”) just prints to the Terminal after the script is completed. I see that rs.Prompt() works fine now, thanks for that!
  • Reset the prompt to “Command:” after a script is completed, now it stays on the last prompt provided.
  • have rhinoscriptsyntax autocomplete (better) like it does in Rhino Python Editor.
  • Being able to scroll the Terminal content sideways
  • Have an autosave on run option, just like the Python Editor does. (old habits are difficult to change, so maybe have this as an option in Preferences)
  • Edit: And keep track of it’s own last used folders for open/save. (Now if I open a Rhino file then RhinoCode also uses that folder when the save/open dialog pops up, and not the folder RhinoCode used last)

And of course be able to run Python 3 scripts from buttons. And compile them to plugins, but from a button is first priority for me personally.

Thanks for listening and for the amazing work you have done!

4 Likes

@Holo This is a great list! Thank you so much.

I added these YTs in order of your bullet points:

Hi @eirannejad,

great work! However I get “Unknown command: Rhinocode”. Has the command been removed again?

Thanks,
Tim

image

Hi Tim -

This is now called ScriptEditor.
-wim

Great! thanks @wim

hi
i’m on an m1 mac, latest wip

when i enter scripteditor, it opens but i cant interact w/ anything

all menu items are greyed out too—only button that works is ‘rhinocode logs’ which displays this:

this is the first time i’ve tried to run the script editor.
any help is appreciated

Hi -

I’m seeing that here as well.
Reported as RH-73170 RhinoCode: ScriptEditor is inactive
-wim