This is an essential scripting guide
This manual is intended for designers who are experienced in Grasshopper® (GH) visual scripting, and would like to take their skills to the next level to create their own custom scripts using C# programming language. This guide does not assume nor require any background in programming. The document is divided into four parts.
- C# Component in Grasshopper explains the general interface of the C# scripting component in Grasshopper.
- C# Programming Basics reviews the basics of the C# DotNet programming language.
- RhinoCommon Geometry covers the main geometry types and functions in the RhinoCommon SDK.
- Design Algorithms includes examples of a number of design algorithms.
The guide includes many examples that are also available as a Grasshopper file available with the download of this guide. Note that all examples are written in version 8 of Rhinoceros® (Rhino) and Grasshopper.
I would like to acknowledge the excellent technical review by Mr. Steve Baer of Robert McNeel and Associates. I would also like to acknowledge Ms. Sandy McNeel for reviewing the writing and formatting of this document.
1. C# Component in Grasshopper
1.1 Introduction
1.2 C# component interface
1.3 The input parameters
1.4 The output parameters
1.5 The out string
1.6 Main menu
1.7 Code editor
1.7.1 Imports
1.7.2 Utility members and functions
1.7.3 The RunScript
1.8 Data access
1.8.1 Item access
1.8.2 Lists access
1.8.3 Tree access
2. C# Programming Basics
2.1 Introduction
2.2 Comments
2.3 Variables
2.4 Operators
2.5 Namespaces
2.6 Data
2.6.1 Primitive data types
2.6.2 Collections
2.7 Flow control
2.7.1 Conditional statements
2.7.2 Loops
2.8 Methods
2.8.1 Overview
2.8.2 Method parameters
2.9 User-defined data types
2.9.1 Enumerations
2.9.2 Structures
2.9.3 Classes
2.9.4 Value vs reference types
2.9.5 Interface
2.10 Read and write text files
2.11 Recursive functions
3. RhinoCommon Geometry
3.1 Overview
3.2 Geometry structures
3.2.1 The Point3d structure
3.2.2 Points and vectors
3.2.3 Lightweight curves
3.2.4 Lightweight surfaces
3.2.5 Lightweight surfaces
3.3 Geometry classes
3.3.1 Curves
3.3.2 Surfaces
3.3.3 Meshes
3.3.4 Boundary representation (Brep)
3.3.5 Other geometry classes
3.4 Geometry transformations
4. Design Algorithms
4.1 Introduction
4.2 Geometry algorithms
4.2.1 Sine curves and surface
4.2.2 De Casteljau algorithm to interpolate a Bezier curve
4.2.3 Simple subdivision mesh
4.3 Generative algorithms
4.3.1 Dragon curve
4.3.2 Fractal tree
4.3.3 Penrose tiling
4.3.4 Conway Game of Life