Rhino WIP: Grasshopper 2 Script Components

First working draft of Grasshopper 2 Script Components are in Rhino WIP. This is the first iteration of these components and there is still a long road to feature parity with Grasshopper 1. But they are there and they are mostly usable. I thought it would be a good idea to announce and collect feedback as early as possible, as we further develop these components.

Here are the highlights on what is available and what is in progress:

  • Python3, IronPython 2, and C# components are available (marked as hidden until ready)
  • Data + Metadata are both accessible using Grasshopper 2 IPear data type
  • Executing and debugging in multi-threaded mode is supported.
  • Language initialization is handled similar to Grasshopper 1 script components
  • Work In Progress
    • Implementation of Script_Instance for grasshopper 2
    • Type hints although data access is simpler that GH1
    • Generic script component that can run any language
    • Parameters to input and output script that the component executes
    • Parameters to input library that the component uses with the script
    • Parameter and component Tooltip/Human-readable Names for publishing
    • Copy/Pasting parameters
    • Add support for Grasshopper 2 to script editor projects
    • Maybe helper libraries like ghpythonlib

Double-click on the GH2 canvas and type # python or #C# to access these components

Double-clicking the component should open the editor just like GH1

Data / Metadata Access

In GH2 script components, grabbing the data is as easy as GH1. Just connect the inputs and the script will receive the data depending on the access kind (Item, List, Tree)

To access the metadata that is accompanying a data item, you can right-click on an input parameter and mark it as “Picks Pears”. This means the data that is passes to the component is now an instance of Grasshopper IPear. You can access the item (IPear.Item) and metadata (IPear.Meta) using this data structure

Note that when access kind is set to Tree, the Picks Pears option is disabled since an instance of Grasshopper ITree is being passed to the script that provides access to the metadata as well

Parallel Execution

By default, Grasshopper 2 creates independent tasks for Iterations of a component and runs them in parallel. You can choose the Threading Model of a script component on the context menu. However debugging a component that is running and computing iterations out-of-order is not very intuitive. So you can choose this independently for debug mode, and it is set to One (one by one on any available thread) by default

Debugging works very similar to GH2 with the exception of parallel debugging that is specific to GH2

Python Marshalling

Just like GH1 you can choose whether to marshal input data to python types or not

Language Init

Language initialization should work normally like GH1


I would love to hear your feedbacks!

8 Likes

Thanks for the work, but I guess access to these features is still for internal builds? Yesterday’s Rhino 9 WIP does not find Python or C# Script Component in Grasshopper 2 (I used the search you showed, preceded by #). My GH2 plugin is also updated to the latest via Package Manager.

Uninstall the GH2 that you have from Package manager. Rhino WIP ships with Grasshopper 2 already. I suspect your Rhino is still loading the one from package manager

This is awesome, congrats @eirannejad. Very exciting news indeed :partying_face:

From a very quick go, I don’t really have too much feedback yet, other than the visual design appears to be largely identical to the Rhino 8 versions. Where in your videos above, the Mac version looks more minimal and pleasing (to me), than the Windows version:

With the top menu bar obliviously being a given, but I think the thicker borders and top left icon are also key culprits, as discussed way back in 2023 here:

If at all possible, I’d still prefer a slightly leaner/minimal overall design/structure, ala this old mock-up:

Edit: Also, reusing the design of the GhPython component icon for the new CPython component might be a bit confusing (i.e. as GhPython was/is IronPython). Maybe a modified CPython logo would be more appropriate.

Edit II: Think I didn’t have enough coffee, I can see now that the WIP/GH2 CPython logo is more like a combination of the old two, I dig it:

Can ghpython in grasshopper 2 support compile and export file *.ghpy just like GH1, can run on GH2
Or can you make *.ghpy can run on GH2 ?
It will help individuals create many small and secure applications.

Or less substantial, these small tweak would go a long way:

From:

To:

Where I’ve:

  1. Made the left/middle borders thin and desaturated (like on Mac).
  2. Removed the top left Rhino WIP icon (like on Mac).
  3. Made the two top right collapse buttons lighter.
  4. Made the three icons at the top bar of the terminal lighter.
  5. Made the terminal background grey (like GhPython).
  6. Desaturated and unified the contrast on borders.

Edit: Still though, something like this would be nice (where the middle bar buttons drop to the bottom):

Only just got the IronPython icon, brilliant:

Very Grasshopper/Rutten-y..

2 Likes

@Shank

We have adopted a new method of publishing script components in Grasshopper as plugins, and it applies to all the supported scripting languages not just IronPython. It does not obfuscate your code however.

See

1 Like