colidescope

/live/ intro-to-python

Welcome! You are not currently logged in. You can Log in or Sign up for an account.

Intro to Python

In this session we get our first hands-on experience working with Python in Grasshopper

+Introduction

In this session we will get hands-on practice with Python in Grasshopper using the Python component and the Rhino.Geometry library.

+Sessions in this webinar series:

Python bootcamp
1Intro to Python
2Elements of 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.

⚠️ You need a member account to access this content.

+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.

⚠️ You need a member account to access this content.

+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.

⚠️ You need a member account to access this content.

+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.

⚠️ You need a member account to access this content.

+Additional resources

For more introductory text-based tutorials covering the basic functionalities of Python, make sure to check out the tutorials included in the https://medium.com/generative-design course on Medium:

If you are new to Python you should also check the Beginner's Guide on the Python webpage.

You can find full documentation of the RhinoCommon library (including the Geometry module we use in the class) in the documentation: https://developer.rhino3d.com/api/RhinoCommon