| Grasshopper Wiki Pages |
| Robert McNeel & Associates |
Summary: Opensource Community page to help support instructors that are teaching the Grasshopper Plugin
The most up to date information is on the Grasshopper Group site. This page may give everyone a place to contribute and learn on teaching the Grasshopper.
This workshop will give students a functional understanding of the grasshopper. Allowing them to build on this understanding into more advanced projects of their own.
Detail explanation on the Interface
Definitions: Shift.ghx
Document: Interface Explained.pdf
Definitions: Simple Math.ghx
* Post-its
The core of Grasshopper is the component. Detailed explanation of components
Document: Objects Explained.pdf
Definition: Need to build up a definition that can be used to create these objects. Perhaps a circle based Definition
Parameters are a special type of component. Many times the place you might start with a definition. Parameters are singular entities that reference or contain data. In traditional programming they are most similar to declared variables. Typically parameters are your starting and controlling values in the definition. There are 3 types of parameters. Geometry, Primitive, and U\I.
Definition: Simple Parameters - Build a definition with Floats and integers see the results. Start with the Multi component. Set a float to each input, see the result. Change one of the inputs, see results. Then run one of the floats through a Int param to round it off.
Definition: Simple Parameters - Build a definition with Points and circles see the results.
Definition: Simple Parameters - Build a definition with Points and circles see the results. Start with the C,N,R Circle component. Add a Point param, set to C. Then set a Float param to R. See the result. Introduce that a param can handle multiple objects. Right click on Point. Then select multiple select. Pick multiple points. You should see many circles. If you want have them draw multiple Rhino points, then select them all with the Point param. You can now move the points around.
Definition: Simple Parameters
These are for primary mathematical functions.
Definition: Simple Math
Definitions: Simple Math.ghx
Definitions: Simple Math.ghx
Definition: Create a cloud of points and a curve. Use and Expression to turn off points that are further from the curve than a specific value.
Definition: Change to include a point on the curve. Then using Boolean gates, set a points that are within the curve and the point.
Definition: Continueing with the Booleans definition above, sort the points based on their distance from an atractor point on the curve. You can use the Tag object to number the points to show their sort order. As an extension, you can draw a circle from the atractor point to the 6th sorted point.
Inside a grasshopper workshop only the most basic of scripting concepts can be presented. A script component can be used to manupulate data in a way that existing components cannot. You can also create geometry with script components. Grasshopper can handle both C# and VB.NET coded components. It is important to note here that Grasshopper does not support RhinoScripting directly. The VB.NET component is the best to use if you are coming from the RhinoScripting language. There are quite a few differences between RhinoScripting and VB.NET, so it will take time to make the transition. This course covers only VB.NET.
Definition: http://en.wiki.mcneel.com/content/upload/files/points_examples.zip
When you drag and drop a VB.NET component you get a base VB.NET code component. By default it has two inputs (x & y) and one output (A). It also has a message output (out) to see error messages.
To edit the component, just double click on the component. You will get a basic code editor -
The areas in Grey you cannot edit. The white background area is where you add your own code.
Each time a piece of data flows into an input, the script you type runs. In the simpliest case a script can be used as a math function. This could also be done with a math function component, but it is used here as a simple example of scripting.
Sub RhinoScript(ByVal angle As Object)
' Set return value to the cosine of the input angle A = Cos(angle)
End Sub
Here you can see that everytime the slider is changed, the code runs in the VB.NET component. The last line of the code states “A =” This is the place that the output value is assigned the the A output on the component.
Also, there is a line the starts with a ” ' ”. This make the line a comment. It is ignored by the code when it runs, but is used to comment the code to hel us understand what is going on.
Perhaps the most important part of VB.NET programming is understanding Variables and Datatypes. Variables are containers of the information. The value of data in a variable can change within your code. It is through variables that you store, edit and retrieve information. There are a few basics to understand about variables.
Variables are containers of information. And, like any real container, depending on what you intend to store in the container you may select from a number of different size and style of containers. It is important to know the type of data you intend to contain in the variable. Each piece of data you will intend to work with has a different size and therefore requires a different size container.
When you create a new Variable in VB.NET you must declare what type (size) the container needs to be in order to hold the information you have.
'This line declares a simple Integer container with the name is i.
Dim i As Int32
* Reference Variable types String, Object.
Dim name As String = "Arthur"
Dim name As Object = "Arthur"
Dim pt As New On3dPoint 'Initialized to (0,0,0) by the default constructor
Dim pt As New On3dPoint(1.0, 2.0, 3.0) 'User initialize point pt.x = 10 'Changing value of a member variable
Sub RhinoScript(ByVal point As ON3dPoint, ByVal dis As Object)
point.x = point.x + (2 * dis) point.y = point.y + (dis * cos(dis)) point.z = point.z
A = point
End Sub * Types * Multiple Outputs - Sometimes you want to output more than one variable each time the loop goes through. For instance if you have two input lists you would like to combine. In this example you have two lists of 5 items each. So you are going to go through your code 5 times. The problem is that you want to output one list with 10 items. So each time through the code, you will want to output two items. To do this you need to use a List object. Dim points As New List(Of On3dPoint)
To add a new member of a list use the .add method
points.Add(new_pt)
Here is a full sample:
Sub RunScript(ByVal x As Object, ByVal y As Object) Dim Sorted As New List(Of Object) Sorted.Add(x) Sorted.Add(y) A = Sorted End Sub
Definition: http://en.wiki.mcneel.com/content/upload/files/points_examples.zip// * opennurbs sample - opennurbs is the way we create and access gemoetry items in Rhino.NET. You can create points, lines and many other geomrty types. * Using opennurbs objects * If you find that you have students that are familiar with “RhinoScript”, you may want to present some of the differences between RhinoScript and Grasshopper's VB.NET code. Some differences between RhinoScript and .NET =====Specialty Components===== * Graph Component * Curve distribution component * Fibonacci sequence component. * Jitter component. * The Post-its as component * Post-It notes can write their contents to text files. Developer tools * EHC files =====Extras=====