Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Grasshopper 2 Script Components in Rhino WIP

$
0
0

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!

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles