In this lesson you will be introduced to the Rhino.Python programming language and the way it relates to the Rhino development environment, including RhinoScript and RhinoCommon. We will learn how to access the Rhino.Python editor and how to navigate its interface and functionalities.
Python for Rhino and Grasshopper
This course is intended for all Rhino users who want to get started with the basics of Rhino.Python scripting or update their RhinoScript skills. Through a series of examples, you will learn how to handle basic Python codes, run macros to automate commands, perform calculations and successfully develop codes for geometry in Rhino 5 for Windows and Mac. You will also learn how to write your own functions, manage different data structures and extend your Grasshopper experience by combining it with iterative and recursive Python codes.
In this course you will learn how to write, debug and optimize our Rhino.Python scripts. We will start by getting familiar with the scripting editor, both in Rhino 5 and Grasshopper, run existing scripts, import and use Rhino functions. We will cover Rhino’s geometrical entities, building through vectors, points, curves, meshes, surfaces and polysurfaces, and analyzing where to find information on all their methods and obtain an understanding of the differences and potentials of different elementary types.
After this course, participants will have the foundations to:
Course at a glance
- 13 lessons – suggested one a day!
- 570 minutes of learning experience
- Quiz available for each lesson
- Certificate of completion available
- Language: English
- Giulio Piacentino
- Assistant: Ilaria Giardiello
PrerequisitesThis course is intended for established Rhino users, who are familiar with Rhino modeling techniques and interface. No previous Rhino.Python experience is required. A basic programing knowledge, though, especially with Python, will allow you to follow the class entirely.
Software requirementsCheck out the introduction lesson to review the software requirements for this course.
In this lesson you will learn how to define functions and how to write functions in modules. We will also learn how to enrich our functions by writing documentation strings to provide some help when using them.
In this lesson you will learn how to implement a for loop statement, to repeatedly execute a piece of code for a certain number of counts, as well as conditional statements to execute a piece of code only if some condition holds.
In this lesson you will learn how to work with Python dictionaries. We will explore how to read and parse an external file and use the information to build our own dictionary.
In this lesson you will learn how to export the results of our code to an external txt file. We will assign, and combine in a formatted string, description and numeric properties to a series of Rhino objects.
In this lesson you will learn how to integrate Rhino.Python codes in your Grasshopper definitions, using the GhPython component. We will explore together how to use dynamic inputs (Grasshopper sliders) to evaluate in real time your code behavior.
In this lesson you will learn how to implement and use, within the context of a recursive function definition, a linear interpolation function (also known as Lerp) to incrementally interpolate values within a numeric interval using a percentage factor.
In this lesson you will learn how to addrees recursive behavior by implementing a function that calls itself. In the example we will show how to build a Koch curve in Grasshopper and dynamically control the level of subdivisions with a slider.
In this lesson you will learn how to address iterative behavior by implementing a function that tests a condition in incremental steps. In the example we will show how to position objects along a free form shape at a minimum distance from each other.
In this lesson you will learn how to build a three-dimensional grid of objects by using a nested loop to define the X, Y and Z coordinate of the base points. We will also construct the logic of an attractor point to define sizes based on distances.
In this lesson you will learn ways to deliver your code to external users, for example by compiling it or embedding it a Rhino button, a SharpDevelop form or a Grasshopper component.
During the course there will be suggested assignments to try to write, while learning, some code on your own. We will review most of the assignments during the course, for this advanced exercise we like to give you a video hint.