• Stars
    star
    133
  • Rank 272,600 (Top 6 %)
  • Language
    C#
  • License
    Apache License 2.0
  • Created about 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Jankless Grasshopper Components

GrasshopperAsyncComponent

Twitter Follow Discourse users Slack Invite website

Less Janky Grasshopper Components

See the companion blog post about the rationale behind this approach. This repo demonstrates how to create an eager and responsive async component that does not block the Grasshopper UI thread while doing heavy work in the background, reports on progress and - theoretically - makes your life easier.

We're not so sure about the last part! We've put this repo out in the hope that others will find something useful inside - even just inspiration for the approach.

uselesscycles

Looks nice, doesn't it? Notice that the solution runs "eagerly" - every time the input changes, the the computation restarts and cancels any previous tasks that are still running. Once everything is done calculating, the results are set. And the best parts:

  • Grasshopper and Rhino are still responsive!
  • There's progress reporting! (personally I hate waiting for Gh to unfreeze...).
  • Thread safe: 99% of the times this won't explode in your face. It still might though!

Approach

Provides an abstract GH_AsyncComponent which you can inherit from to scaffold your own async component. There's more info in the blogpost on how to go about it.

Checkout the sample implementation!

  • Prime number calculator Calculates the n'th prime. Can actually spin your computer's fans quite a bit for numbers > 100.000!
  • Usless spinner does no meaningfull CPU work, just keeps a thread busy with SpinWait().

Current limitations

Main current limitation is around data matching. Solved! See this PR. Components inheriting from the GH_AsyncComponent class can now nicely handle multiple runs and any kind of data matching:

oneproblemsolved

Flash of null data Solved! These Async Components now only expire their downstream dependants when they're done with their tasks.

lookmanoflash-2

Other limitations:

  • This approach is most efficient if you can batch together as many iterations as possible. Ideally you'd work with trees straight away.

  • Task cancellation is up to the developer: this approach won't be too well suited for components calling code from other libraries that you don't, or can't, manage.

FAQ

Q: Does this component use all my cores? A: OH YES. It goes WROOOM.

image

Q: Can I enable cancellation of a longer running task?

A: Yes, now you can! In your component, just add a right click menu action like so:

    public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
    {
      base.AppendAdditionalMenuItems(menu);
      Menu_AppendItem(menu, "Cancel", (s, e) =>
      {
        RequestCancellation();
      });
    }

Debugging

Quite easy:

  • Clone this repository and open up the solution in Visual Studio.
  • Once you've built it, add the bin folder to the Grasshopper Developer Settings (type GrasshopperDeveloperSettings in the Rhino command line) and open up Grasshopper.
  • You should see a new component popping up under "Samples > Async" in the ribbon.
  • A simple

Contributing

Please make sure you read the contribution guidelines and Code of Conduct for an overview of the best practices we try to follow.

Community

The Speckle Community hangs out on the forum, do join and introduce yourself & feel free to ask us questions!

Security

For any security vulnerabilities or concerns, please contact us directly at security[at]speckle.systems.

License

Unless otherwise described, the code in this repository is licensed under the Apache-2.0 License. Please note that some modules, extensions or code herein might be otherwise licensed. This is indicated either in the root of the containing folder under a different license file, or in the respective file's header. If you have any questions, don't hesitate to get in touch with us via email.

More Repositories

1

speckle-server

The Speckle Server, Frontend, 3D Viewer, & other JS utilities.
TypeScript
645
star
2

speckle-sharp

.NET SDK, Schema and Connectors: Revit, Rhino, Grasshopper, Dynamo, ETABS, AutoCAD, Civil3D & more.
C#
356
star
3

xUnitRevit

xUnit runner for Revit
C#
111
star
4

specklepy

Python SDK 🐍
Python
110
star
5

speckle-unreal

Unreal Engine 4/5 plugin for importing objects from Speckle v2.
C++
56
star
6

speckle-unity

AEC Interoperability for Unity through Speckle
C#
55
star
7

speckle-blender

Python
49
star
8

speckle-powerbi

TypeScript
35
star
9

speckle-qgis

QGIS Connector for Speckle 2.0
Python
34
star
10

speckle-powerbi-visuals

Custom Speckle visuals for PowerBI
TypeScript
28
star
11

speckle-aectech-masterclass

web app for comparing Speckle stream commits
Vue
27
star
12

speckle-docs

Documentation on everything Speckle
JavaScript
23
star
13

speckle-excel

Speckle connector for Excel
Vue
18
star
14

SpeckleHackathon-SpeckleReports

Retreat Hackathon: Automated carbon cost reports with real-time notifications
Vue
16
star
15

speckle-examples

All the Speckle examples in one place
Jupyter Notebook
16
star
16

speckle-sketchup

Ruby
15
star
17

tabular-view-vue

Simple table view for Speckle data based on Vue.
Vue
14
star
18

revit-dashboard

Cool Speckle Dashboard for Revit data
Vue
11
star
19

speckle-docs-OLD

Documentation on everything Speckle
JavaScript
11
star
20

SpeckleHackathon-ImgToPointCloud

Jupyter Notebook
10
star
21

speckle_automate_python_example

Example function written for Speckle Automate in python
Python
9
star
22

aec-tech-presentation

JavaScript
8
star
23

speckle-arcgis

ArcGIS Connector for Speckle 2.0
Python
8
star
24

SpeckleAutomateDotnetExample

Example Speckle automate function using the dotnet SDK
C#
7
star
25

sketchup-sqlite3

SketchUp compatible SQLite3 compiler library
C
7
star
26

speckle-sharp-connectors

Speckle Connectors V3
C#
7
star
27

speckle-sharp-sdk

The Speckle SDK/Core for V3
C#
7
star
28

webhooks-demo

Python
6
star
29

speckle-demo-app

Dev Guides: Vue.js App communicating with a Speckle Server
JavaScript
6
star
30

oneclick-c4d

Python
5
star
31

speckle_automate-urban-wind-simulation

Python
5
star
32

helm

Smarty
4
star
33

speckle_automate_jupyter_example

Jupyter Notebook
4
star
34

.github

The .github repo for Speckle
3
star
35

speckle-unity-vr

ShaderLab
3
star
36

speckle-automate-github-action

GitHub Action for creating Speckle Automate Functions
TypeScript
3
star
37

manager-feed

Feed for Speckle Manager
2
star
38

speckle-email-templates

MJML development environment for building e-mail templates
2
star
39

speckle-automate-github-composite-action

A GitHub Action to build, publish, and register a Docker Image as a Speckle Automate Function
2
star
40

github-actions

Home of all shared Github Actions and Workflows at Speckle
1
star
41

speckle_automate-basic_clash_demo

Python
1
star
42

specklepy_qt_ui

Python
1
star
43

CSiAPIPlayground

A very simple playground for testing CSi API functionality
C#
1
star
44

speckle-sharp-host-apis

Speckle generated apis for various Host Applications.
C#
1
star
45

BILT-Workshop-Demo-Function

Python
1
star
46

Regression-Testing

C#
1
star