algorithmic modeling for Rhino
I'm going to post here some examples of writing simple C# scripts which use the Kangaroo library for custom iterative behaviour. While I have posted a number of examples of custom goals before, so far I've not shown much about such custom looping.
This can be useful because it allows you to make changes in topology (such as which goals act on which particles, or the number of particles in the simulation), which would be difficult or impossible using only the standard components.
Please let me know if you have any questions about these files, or requests for other types of examples.
For all of these scripting examples, the first time you open them you will need to set the location of the KangarooSolver.dll on your system.
I think the easiest way to do this is to use File>Special Folders>Components Folder to navigate to your libraries folder, and copy the path. Then right click the script component on the canvas, and Manage Assemblies. Select and delete the KangarooSolver reference which is there, then choose Add, paste the path you copied earlier, and select your local copy of KangarooSolver.dll
After you have done this once, it should be easier with future files, as the dll will then show up in the recent assemblies tab, and you can simply drag it over.
Example 1: AddingPoints.gh
Starting with something simple - this takes a collection of points, pulls them to a mesh, with collisions between them, and adds a new point at each iteration. Note that here the PhysicalSystem object is actually being created anew at each iteration, with the point locations the only thing preserved between iterations.
Example 2: GrowingLine.gh
This is an updated version of a file I previously posted here. I've cleaned it up a bit to hopefully make it easier to follow. Unlike the first example, this actually maintains the physical simulation from one iteration to the next. It includes a custom goal for the collisions, as the one in the current compiled component did not have a constructor allowing you to assign the Indexing directly.