C# for Grasshopper
The goal of this two day workshops is to introduce the key programming concepts which will allow the participants to extend their capabilities as computational designers. The focus is put on C# language which is fully supported by Rhino+Grasshopper environment. The short duration of workshops allow for building fundamentals to continue own studies on more complex problems. Knowing how to code opens almost endless possibilities of enriching, speeding-up and "hacking" a computational designer's workflow.The course is addressed to people with no to little experience in coding, but a certain proficiency in parametric design is required. We won't cover plugin development and instead focus on scripting directly in Grasshopper. However, an advanced development environment (Visual Studio) will be presented along with the GIT repositories. The meetings will include both tutorials and revision exercises. The participants will receive handouts and additional exercises to do after the workshops.
Focus will be put on techniques which are environment-specific and hard to find in literature or online tutorials.
Part 1: Introduction to programming in C#
This part will cover the basics which are required to start scripting in Grasshopper.
- Setting up the C# scripting component
- Structure of the code
- Concept of variables
- C# data types
- Operators
- Program-flow control with conditional statements
- Program-flow control with loops
- Data sets: lists and arrays
Part 2: Introduction to object-oriented programming
- Understanding the concept of object-oriented programming is necessary to grasp how Rhinoceros and Grasshopper are structured "under the hood".
- Understanding code reusability: methods
- Understanding modularity: creation and use of classes
Part 3: Rhino and Grasshopper specific techniques
Each programming environment has its own specifics. In order to be able to fluently script, one needs to learn and understand how the so-called libraries (in this case RhinoCommon) are structured.
- Basic geometry
- DataTrees
- Advanced geometry
- Transformations
- Reading and writing files
Part 4: Additional scripting techniques
There are some techniques very specific to scripting in Grasshopper which often prove to be helpful.
- Display overriding
- Persistent data
- Debugging: throwing and catching exceptions
- Skimming through fundamental programming concepts and quickly moving to "attractive" tricks. In fact learning basics should be most important, because they allow you to work and discover new things on your own.
- Creative coding tutors often tell you can omit technical knowledge and learn only "exciting" material. Although it can work in a short term, you would quickly forget all concepts learned by heart. Understatement lasts longer.
- Presenting long and complicated scripts instead of short, useful formulas.
- Putting too much pressure on using Visual Studio and plugin development. The fact is most of your scripts will be project-specific and drafted quickly.Based on these observations we created a new program for the workshops.