Rhino 8 Feature: ScriptEditor (CPython, CSharp)

That looks super cool and convenient :slight_smile:

One quick question: Can the script component inputs (x,y) and outputs (a) be defined in the script or do you still have to add and type those using the GH UI? What I mean is if I want to change the function to a = x + y + z, then would I have to add the input for z myself or is there some way where these can be added automatically depending on whatā€™s defined in the script?

Either way, I have to say all the development around script editing looks super impressive and I canā€™t wait to play with it more.

1 Like

Currently you have to modify inputs using the component UI. Determining which variable is an input is quite hard and might need some sort of convention like adding #! input: z to the top of the script. Hopefully we can find a good workflow for this and add it in the future to all script components using a shared script can update their parameters

3 Likes

Thanks for the detailed answer on the script file handling problem :slight_smile:

Do you have a clue about this topic (kind of problematic right now but we can still manually install the package) :

And this one which is really annoying :

As for this last topic, if a script component refers to code from an external file and this file uses import statement of another file next to it, I encounter a random behaviour, sometimes the import statement works properly and sometimes it cannot find the file ā€¦ Iā€™m a bit lost there.
Example : files toto.py and utils.py are in a folder, toto.py is used by the component, toto.py has ā€œimport utilsā€, the import fails randomly from time to timeā€¦

1 Like

Hmm this is interesting. Okay let me run a few tests on those. ( RH-75516 Python linked script does not import python files in the same directory when used in Grasshopper component)

The other two mentioned above I have YT tickets for which Iā€™m working on in the next few days.

RH-75515 Allow using custom package sources

RH-75468 Implement resetting script engine specifically to reload libraries

1 Like

Hi,
Iā€™m trying to use new script editor to debug a code that I had written in grasshopper C# component.
I have some int and double inputs with list access and im trying to use LINQ library. my script works correctly in C# component but when I try to re write in new script editor Iā€™m getting following error:

Compile Error
cannot convert from 'System.Collections.Generic.List<object>' to 'int' (Error CS1503: Argument 1) rhinocode:///grasshopper/1/255b438e-20c1-4e9b-bcae-869665a4809e/2131910e-b5d3-4f3d-8808-c34400c33ade:[85:44]

I have already imported LINQ on top of the script. one thing I noticed in C# script editor inputs with List access are defined as List while in the new editor they are defined as System.Collections.Generic.IEnumerable. could that be the issue?

Iā€™ve also added the both C# component and script editor components for reference in the gh file.

Thanks

gh script component.gh (16.1 KB)

When I use #r "nuget: RestSharp, 106.11.7"
The following is an error message:
Info 07/10/2023 07:11:11 [RhinoCode] Execute started
Error 07/10/2023 07:11:11 [RhinoCode] Error executing code | System.Exception: Error installing nuget package RestSharp==106.11.7
ā€”> System.NullReferenceException: Object reference not set to an instance of an object.
at NuGet.Protocol.DownloadResourceV3.GetDownloadUrl(PackageIdentity identity, ILogger log, CancellationToken token)
at NuGet.Protocol.DownloadResourceV3.GetDownloadResourceResultAsync(PackageIdentity identity, PackageDownloadContext downloadContext, String globalPackagesFolder, ILogger logger, CancellationToken token)
at Rhino.Runtime.Code.Environments.NugetEnviron.InstallAsync(NugetEnviron environ, NuGetSpec spec)
at Rhino.Runtime.Code.Environments.NugetEnviron.<>c__DisplayClass29_0.<b__0>d.MoveNext()
ā€” End of stack trace from previous location ā€”
at Rhino.Runtime.Code.Environments.NugetEnviron.AddPackage(PackageSpec pkgSpec)
at Rhino.Runtime.Code.Environments.NugetEnviron.AddPackages(IEnumerable`1 pkgSpecs)
ā€” End of inner exception stack trace ā€”
at Rhino.Runtime.Code.Code.BeginRun(ExecuteContext context)
at Rhino.Runtime.Code.Code.Run(ExecuteContext context)
at RhinoCodeEditor.Editor.Commands.WithExecutableCodeCommand.ExecuteCodeContext.RunCode()
Info 07/10/2023 07:11:11 [RhinoCode] Execute ended

1 Like

Are there any plans for syntax highlighting of Rhino data types?

1 Like

@rudi Is this in C# or python?

I added internalized data to components

gh script component.gh (29.1 KB)

Hey Ehsan I am writing C# in the Grasshopper native script editor that comes with RH8 WIP!
The image is a VisualStudio screenshot from a YT video

Cheers

Can anyone point me in the right direction in understanding this new script window and the python 3 frame work. I see chatter about being able to install packages. Can I tap into a Rhino python virtual environment ? Is there some kind of guide showing some of the new advantages to the python3 framework ?

Hi devs,

please can someone fix the menu for international use: -ScriptEditor doesnā€™t work here, please fix it to -_ScriptEditor.

Thanks

Michael

1 Like

This is fixed for the next WIP :smiley: Thanks for catching it

1 Like

No virtual environment support as of yet. But you can install pip packages for your script like this. See the line specifying required package (# r: numpy)

"""Testing pip install specific packages"""
# r: numpy

import numpy

# print(numpy)
print(f"using numpy: {numpy.version.full_version}\n")

for i in numpy.random.rand(10):
    print(i)

Hiā€¦,

how to switch off the blue underline marker for ā€œView Problemā€.

no_help_please

They distract me, from writing code.

Thanks

Michael

Hi again,

the Script Editor window stays always in front of the Rhino window.

When I want to draw something in Rhino, I have to minimize the Script Editor window or move it away. This is annoying.

Wish: I would like to click on the Rhino window to bring it in front of the Script Editor window and vice versa.

Thanks

Michael

Look at the warnings tab at the bottom of the editor. It might say something like empty line missing afterā€¦

Hi Martin,

yes, I see the (style-)warnings, which I donā€™t care. :wink:

I want to switch off all blue underlines of the style warnings, they look distracting to me, my eyes hurt.

Thanks

Michael

BTW: I am a fast typist, and the auto-style-correction tries to improve my typing in the background, and produces hickups and delays. This editor is hard for me at the moment. :frowning:

Also I get crashes from the Script Editor, here a crash report:
RhinoDotNetCrash.txt (1.2 KB)

1 Like

Indeed, so does mine. You can right-click the editor window and select Language Options and then disable Diagnostics (Linting). I assume this works in the non-Grasshopper editor as well. I wasnā€™t able to find this under the main/top menu bar:


2 Likes

Hi Anders,

yes, this works. I was looking in the menu Edit/Options, and found just a lonely font setting, which seams not to work (found it, works only for new files, weird).

Thank you very much

Michael

1 Like