Rhino 8 Feature: RhinoCode (CPython, CSharp)

Hello :wave:

RhinoCode is a new scripting toolchain for Rhino and has been finally added to the Rhino 8 WIP installers for both macOS and Windows.

This first draft of RhinoCode provides:

  • Modern code editor with linting and autocomplete
  • Python 3.9 and PIP package manager
  • C# 9 scripting and NuGet package manager

Run the rhinocode command in Rhino prompt to open the editor.

There are more features planned but meanwhile, we would love to hear your thoughts, comments, bug reports, and also feature requests here :slight_smile:

53 Likes

So cool! It’s about to get numpy in here.

6 Likes

@eirannejad

This looks amazing - it’s got me tempted to just forgo the rest of the Rhino 7 demo period and buy it right now just so I can get my hands on 8 to start playing around with this functionality.

How and where are you storing the environment?

I use conda, so I wasn’t sure if there was any thought given about being able to point it at a manually created conda environment and run everything through there.

Even being able to point Rhino at the conda install and having it integrate that way (and automagically setup the conda environment) would be wonderful.

3 Likes

Absolutely stunning! Thanks.
Just a quick test:

10 Likes

Feature request: source control! :slightly_smiling_face:

2 Likes

Fortunately you can do that by just installing your favourite source control tools.

2 Likes

Great News!
Can’t wait for it.

1 Like

Kudos for demoing this on macOS! Great progress.

Like virtualenv and stuff? Should be possible, since pip is supported, right?

1 Like
def thank(names: list[str]) -> None:
    print(f"Thanks {', '.join(names[:-1])} and {names[-1]}!")

if __name__ == "__main__":
    thank(["Ehsan Iran-Nejad", "everybody else"])

:grin:

3 Likes

Of course. But a gui inside the editor would be nice too.
Also how’s that going to work for a C# or a Python script that’s inside a GH file? Would be nice to push and pull to/from a remote server inside GH.

1 Like

Maybe a few cents on my workflow:

I also use conda to manage my working environement. This is because I have custom packages that are not pip-install-able and some packages are “editable” local libraries (I am developing those libraries).

As part of development, I also switch my conda environment frequently. It would be nice if there is a way to select my conda environment (similar to how I would work in VS code and select an interpreter) for Rhino Python code to run in.

3 Likes

:tada: early christmas!! @stevebaer @eirannejad you guys intend to bring this to gh as well? cause that would rock

6 Likes

Hi David -

From what I understand, yes, that’s the plan.
-wim

4 Likes

Hi this is great to see!

I pulled in an old piece of Python and the first thing that hit me was the formatting nanny. It created a rash of disapproval all over my neatly presented but nonconformant code. Any chance we could turn this off until such time as we can configure it to our own idiosyncrasies?

Thanks
Jeremy

4 Likes

Of course

4 Likes

Does this tool override/replace the EditPythonScript UI / area?

1 Like

EditPythonScript will remain in Rhino and continue to use IronPython 2 until we have a complete replacement with RhinoCode.

2 Likes

Will this work with Visual Studio for the development of C++ DLL with procedures that can be called from Python? I do this now with Visual Studio 2019 (VS 2019) and IronPython in Rhino 7. In Visual Studio Debug mode, Rhino will automatically be started and then I can run my Python script which will call the C++ procedures in the C++ DLL. If there is a exception in the C++ code, then the offending line will be highlighted in the C++ editor.

When transitioning from VS 2017/Rhino 6 to VS 2019/Rhino 7, a setting had to be updated so that the debugger would start up Rhino 7 instead of Rhino 6. I think this will need to be done for Rhino 8 also.

Normally Visual Studio is used to create C++ plugin for Rhino. But it only takes a few modifications for this flow to generate a C++ DLL with procedures callable from Python using a C-types interface for passing the variables to/from the C++ code. Having this capability is key to improving Python performance over 100x for many applications.

If the above will be possible, how long will it be for the Plugin/C++ DLL flow to support Visual Studio 2022 which came out this month? VS 2022 supports C++ 20 which has more features. It would be exciting to have the capability to run VS 2022 with C++ 20 to generate C++ DLL for use with RhinoCode with Python 3.9 support.

Regards,
Terry.

1 Like

Yes, that is the command to execute when starting a debug session. This is under the Debugger properties for your project.

I would imagine this is already possible. We are currently at the early stages of going through the transition of from building Rhino in VS2019 to VS2022 which amounts to one developer figuring things out and then helping the rest of the team migrate. That said, you should be able to use VS2022 today for your own project.

1 Like

How are the colors chosen for the display? Can barely read text on some of the dialogs.

1 Like