feat(sample & readme): added a small sample file and added extra info in the readme file

This commit is contained in:
Dimitrie Stefanescu 2020-10-04 23:19:46 +01:00
Родитель 011a28df6a
Коммит 48f8d6a7ed
2 изменённых файлов: 301 добавлений и 1 удалений

Просмотреть файл

@ -1,2 +1,43 @@
# GrasshopperAsyncComponent
Jankless Grasshopper Components
[![Twitter Follow](https://img.shields.io/twitter/follow/SpeckleSystems?style=social)](https://twitter.com/SpeckleSystems) [![Discourse users](https://img.shields.io/discourse/users?server=https%3A%2F%2Fdiscourse.speckle.works&style=flat-square)](https://discourse.speckle.works)
[![Slack Invite](https://img.shields.io/badge/-slack-grey?style=flat-square&logo=slack)](https://speckle-works.slack.com/join/shared_invite/enQtNjY5Mzk2NTYxNTA4LTU4MWI5ZjdhMjFmMTIxZDIzOTAzMzRmMTZhY2QxMmM1ZjVmNzJmZGMzMDVlZmJjYWQxYWU0MWJkYmY3N2JjNGI) [![website](https://img.shields.io/badge/www-speckle.systems-royalblue?style=flat-square)](https://speckle.systems)
## 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.
INSERT GIF HERE
### 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.
Even better, there's a sample component that shows how an implementation could look like! TODO: link to code!
### Current limitations
Main current limitation is around data matching. If the component needs to run more than once - e.g., in the case of `Item` input parameters receiving a `List` of objects, it gets stuck. Currently, the safest bet - albeit not the easiest one - is to make sure your input parameters are set to `Tree` and you can do your own data matching inside. Not ideal, I know. I'm sure this can be improved, but it's late on a Sunday evening.
### 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
Before embarking on submitting a patch, please make sure you read:
- [Contribution Guidelines](CONTRIBUTING.md),
- [Code of Conduct](CODE_OF_CONDUCT.md)
## License
Unless otherwise described, the code in this repository is licensed under the Apache-2.0 license.

259
SampleGhFile.ghx Normal file
Просмотреть файл

@ -0,0 +1,259 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Archive name="Root">
<!--Grasshopper archive-->
<!--Grasshopper and GH_IO.dll are copyrighted by Robert McNeel & Associates-->
<!--Archive generated by GH_IO.dll file utility library {0.2.0002}-->
<items count="1">
<item name="ArchiveVersion" type_name="gh_version" type_code="80">
<Major>0</Major>
<Minor>2</Minor>
<Revision>2</Revision>
</item>
</items>
<chunks count="2">
<chunk name="Definition">
<items count="1">
<item name="plugin_version" type_name="gh_version" type_code="80">
<Major>1</Major>
<Minor>0</Minor>
<Revision>7</Revision>
</item>
</items>
<chunks count="5">
<chunk name="DocumentHeader">
<items count="5">
<item name="DocumentID" type_name="gh_guid" type_code="9">7b7a4534-415e-40d2-85bf-2e969bf8cbda</item>
<item name="Preview" type_name="gh_string" type_code="10">Shaded</item>
<item name="PreviewMeshType" type_name="gh_int32" type_code="3">1</item>
<item name="PreviewNormal" type_name="gh_drawing_color" type_code="36">
<ARGB>100;150;0;0</ARGB>
</item>
<item name="PreviewSelected" type_name="gh_drawing_color" type_code="36">
<ARGB>100;0;150;0</ARGB>
</item>
</items>
</chunk>
<chunk name="DefinitionProperties">
<items count="3">
<item name="Date" type_name="gh_date" type_code="8">637374490990396611</item>
<item name="Description" type_name="gh_string" type_code="10"></item>
<item name="Name" type_name="gh_string" type_code="10">SampleGhFile.ghx</item>
</items>
<chunks count="3">
<chunk name="Revisions">
<items count="1">
<item name="RevisionCount" type_name="gh_int32" type_code="3">0</item>
</items>
</chunk>
<chunk name="Projection">
<items count="2">
<item name="Target" type_name="gh_drawing_point" type_code="30">
<X>-16</X>
<Y>-11</Y>
</item>
<item name="Zoom" type_name="gh_single" type_code="5">1.38408291</item>
</items>
</chunk>
<chunk name="Views">
<items count="1">
<item name="ViewCount" type_name="gh_int32" type_code="3">0</item>
</items>
</chunk>
</chunks>
</chunk>
<chunk name="RcpLayout">
<items count="1">
<item name="GroupCount" type_name="gh_int32" type_code="3">0</item>
</items>
</chunk>
<chunk name="GHALibraries">
<items count="1">
<item name="Count" type_name="gh_int32" type_code="3">1</item>
</items>
<chunks count="1">
<chunk name="Library" index="0">
<items count="6">
<item name="AssemblyFullName" type_name="gh_string" type_code="10">GrasshopperAsyncComponent, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</item>
<item name="AssemblyVersion" type_name="gh_string" type_code="10">1.0.0.0</item>
<item name="Author" type_name="gh_string" type_code="10"></item>
<item name="Id" type_name="gh_guid" type_code="9">9c8808bc-ddee-45ca-8c66-05ca3cf4d394</item>
<item name="Name" type_name="gh_string" type_code="10">GrasshopperAsyncComponent</item>
<item name="Version" type_name="gh_string" type_code="10"></item>
</items>
</chunk>
</chunks>
</chunk>
<chunk name="DefinitionObjects">
<items count="1">
<item name="ObjectCount" type_name="gh_int32" type_code="3">3</item>
</items>
<chunks count="3">
<chunk name="Object" index="0">
<items count="2">
<item name="GUID" type_name="gh_guid" type_code="9">c552a431-af5b-46a9-a8a4-0fcbc27ef596</item>
<item name="Name" type_name="gh_string" type_code="10">Group</item>
</items>
<chunks count="1">
<chunk name="Container">
<items count="8">
<item name="Border" type_name="gh_int32" type_code="3">1</item>
<item name="Colour" type_name="gh_drawing_color" type_code="36">
<ARGB>150;170;135;255</ARGB>
</item>
<item name="Description" type_name="gh_string" type_code="10">A group of Grasshopper objects</item>
<item name="ID" index="0" type_name="gh_guid" type_code="9">218540d4-f247-46f0-9a31-102d00304a2e</item>
<item name="ID_Count" type_name="gh_int32" type_code="3">1</item>
<item name="InstanceGuid" type_name="gh_guid" type_code="9">76fc2096-4cf4-4832-b9b8-65b28695b903</item>
<item name="Name" type_name="gh_string" type_code="10">Group</item>
<item name="NickName" type_name="gh_string" type_code="10">Does meaningless labour. Spins some cycles!</item>
</items>
<chunks count="1">
<chunk name="Attributes" />
</chunks>
</chunk>
</chunks>
</chunk>
<chunk name="Object" index="1">
<items count="2">
<item name="GUID" type_name="gh_guid" type_code="9">57da07bd-ecab-415d-9d86-af36d7073abc</item>
<item name="Name" type_name="gh_string" type_code="10">Number Slider</item>
</items>
<chunks count="1">
<chunk name="Container">
<items count="6">
<item name="Description" type_name="gh_string" type_code="10">Numeric slider for single values</item>
<item name="InstanceGuid" type_name="gh_guid" type_code="9">fadc4348-0eb2-42b5-b744-04478b2a90ae</item>
<item name="Name" type_name="gh_string" type_code="10">Number Slider</item>
<item name="NickName" type_name="gh_string" type_code="10"></item>
<item name="Optional" type_name="gh_bool" type_code="1">false</item>
<item name="SourceCount" type_name="gh_int32" type_code="3">0</item>
</items>
<chunks count="2">
<chunk name="Attributes">
<items count="2">
<item name="Bounds" type_name="gh_drawing_rectanglef" type_code="35">
<X>98</X>
<Y>191</Y>
<W>202</W>
<H>20</H>
</item>
<item name="Pivot" type_name="gh_drawing_pointf" type_code="31">
<X>98.71039</X>
<Y>191.433</Y>
</item>
</items>
</chunk>
<chunk name="Slider">
<items count="7">
<item name="Digits" type_name="gh_int32" type_code="3">3</item>
<item name="GripDisplay" type_name="gh_int32" type_code="3">1</item>
<item name="Interval" type_name="gh_int32" type_code="3">1</item>
<item name="Max" type_name="gh_double" type_code="6">1000</item>
<item name="Min" type_name="gh_double" type_code="6">0</item>
<item name="SnapCount" type_name="gh_int32" type_code="3">0</item>
<item name="Value" type_name="gh_double" type_code="6">769</item>
</items>
</chunk>
</chunks>
</chunk>
</chunks>
</chunk>
<chunk name="Object" index="2">
<items count="3">
<item name="GUID" type_name="gh_guid" type_code="9">df2b93e2-052d-4be4-bc62-90dc1f169bf6</item>
<item name="Lib" type_name="gh_guid" type_code="9">9c8808bc-ddee-45ca-8c66-05ca3cf4d394</item>
<item name="Name" type_name="gh_string" type_code="10">Sample Async Component</item>
</items>
<chunks count="1">
<chunk name="Container">
<items count="4">
<item name="Description" type_name="gh_string" type_code="10">Meaningless labour.</item>
<item name="InstanceGuid" type_name="gh_guid" type_code="9">218540d4-f247-46f0-9a31-102d00304a2e</item>
<item name="Name" type_name="gh_string" type_code="10">Sample Async Component</item>
<item name="NickName" type_name="gh_string" type_code="10">ASYNC</item>
</items>
<chunks count="3">
<chunk name="Attributes">
<items count="2">
<item name="Bounds" type_name="gh_drawing_rectanglef" type_code="35">
<X>410</X>
<Y>172</Y>
<W>69</W>
<H>59</H>
</item>
<item name="Pivot" type_name="gh_drawing_pointf" type_code="31">
<X>444</X>
<Y>202</Y>
</item>
</items>
</chunk>
<chunk name="param_input" index="0">
<items count="7">
<item name="Description" type_name="gh_string" type_code="10">How many useless cycles should we spin. Minimum 10, maximum 1000.</item>
<item name="InstanceGuid" type_name="gh_guid" type_code="9">d89ad114-fb4c-4bbc-9a0c-d0a430acdbe9</item>
<item name="Name" type_name="gh_string" type_code="10">Max iterations</item>
<item name="NickName" type_name="gh_string" type_code="10">M</item>
<item name="Optional" type_name="gh_bool" type_code="1">false</item>
<item name="Source" index="0" type_name="gh_guid" type_code="9">fadc4348-0eb2-42b5-b744-04478b2a90ae</item>
<item name="SourceCount" type_name="gh_int32" type_code="3">1</item>
</items>
<chunks count="1">
<chunk name="Attributes">
<items count="2">
<item name="Bounds" type_name="gh_drawing_rectanglef" type_code="35">
<X>412</X>
<Y>174</Y>
<W>17</W>
<H>55</H>
</item>
<item name="Pivot" type_name="gh_drawing_pointf" type_code="31">
<X>422</X>
<Y>201.5</Y>
</item>
</items>
</chunk>
</chunks>
</chunk>
<chunk name="param_output" index="0">
<items count="6">
<item name="Description" type_name="gh_string" type_code="10">Will just say hello world after spinning.</item>
<item name="InstanceGuid" type_name="gh_guid" type_code="9">95cec75f-9dc0-49c5-a502-c2445299cb1b</item>
<item name="Name" type_name="gh_string" type_code="10">Output</item>
<item name="NickName" type_name="gh_string" type_code="10">O</item>
<item name="Optional" type_name="gh_bool" type_code="1">false</item>
<item name="SourceCount" type_name="gh_int32" type_code="3">0</item>
</items>
<chunks count="1">
<chunk name="Attributes">
<items count="2">
<item name="Bounds" type_name="gh_drawing_rectanglef" type_code="35">
<X>459</X>
<Y>174</Y>
<W>18</W>
<H>55</H>
</item>
<item name="Pivot" type_name="gh_drawing_pointf" type_code="31">
<X>468</X>
<Y>201.5</Y>
</item>
</items>
</chunk>
</chunks>
</chunk>
</chunks>
</chunk>
</chunks>
</chunk>
</chunks>
</chunk>
</chunks>
</chunk>
<chunk name="Thumbnail">
<items count="1">
<item name="Thumbnail" type_name="gh_drawing_bitmap" type_code="37">
<bitmap length="1690">iVBORw0KGgoAAAANSUhEUgAAAJYAAABkCAIAAADrOV6nAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAYvSURBVHhe7djdT1N3GMBx/4Ilc4Mr47yYF1544dSRgQRNFjMZOAcki0u8MjGSEITgUHlXBjK0trQU2tKWQmkptNAXqMA6xNIyxLdKteVd+g5svMjY3J3uoafilm2ueLHwtM8nv5ycnnNKyfn6+3HqNhIJXhK0Xif0EoQoIXqUED1KiB4lRI8SokcJ0aOE6FFC9CghepQQPUqIHiVEjxKiRwnRo4ToUUL0KCF6lBA9SogeJUSPEqJHCdGjhOhFTkKfb3MjYkROQtfmuENvwy8SEvoD3ulJ123t/KB2yaJbeTWeWfWvx8ZB2Jo7lyzdAbfbHRlzMUISTk24BtpXB1RrPQpfr9Lbq/D2tfq7m13MuNnigZdwMDgCA6rnZu0izERKuFUwCW+r13pU049G7Q7HxNjYtNls7QjS6XR6vf7Bg1Gnc9LpnLh719Yj91n0K9GY0Pe/CH3YZjAJzepfDXJHl9HUbTT39Q3z+eKSkqJafu111rW8vDy1pqe312o0mvUGk7HZbTU8i66EcGc9Hvfs7KzLFc5wPX1bMzMzwTu7uVvLJBzs+E0reyyVtctkWoXCeOXK9dTUzyUSycWLF1JSUkUilVxugFONjZ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