¶Sessions in this webinar series:
|1||Intro to Python|
|2||Elements of Python|
¶Introduction to Python
¶Demo: Data inputs and outputs
In this demo, we get our first hands-on experience working with Python in Grasshopper. As a starting point, we look at how to input data from Grasshopper into a Python script running within a Python component, and how to handle geometric inputs. We also look at how to output data from Python back to the Grasshopper canvas.
¶Demo: Creating geometry in Python
In this lesson, we look at how we can create geometry in Python using the Rhino.Geometry library. We first import the library using an
import statement and then create a circle using a point input from Grasshopper as its center.
¶Demo: Working with lists and loops
In this lesson, we extend our script to accommodate multiple points from Grasshopper. We look at how we can work with lists in Python, and how to iterate over the objects in a list using a loop.
¶Demo: Adding an attractor point
In the final lesson of the session, we finish our script by adding the ability to control the radius of each circle in the grid based on the distance of each point to another point called the 'attractor'. We first calculate the radius directly from the distance and then use a set of conditional statements to set the radius directly based on the distance meeting certain criteria.