designcoding
About Table of Contents Keywords Monthly Archive
Support designcoding!

Hexagonal grid with Rhino Python

July 25, 2017 | Algorithms
#grid #hexagon #rhino-python

This python code proves how much effort it takes to create a simple hexagonal tessellation. There are, of course, much easier and faster methods than this. But here you see a code that introduces students to Rhino Python. Using this code, a new Rhino command can be generated, and for the first time in Rhino, we can have a command that creates a hexagonal grid. I followed this tutorial to turn this Python script into a Rhino command. This is also educational. Because I sometimes want my design mathematics students to mimic a Rhino command in Python. Then, I ask them to improve one of the commands. This is a nice example of further improvements. A student can follow this and lead the hexagonal grid code to a hexagonal array command, for example.

Hexagonal grid with Rhino Python grid, hexagon

The below Python code uses the rhinoscriptsyntax module to draw the hexagonal grid. As you can read, it draws the hexagons by dividing a circle. Because Rhino Python in 2017 doesn’t have a polygon method. I hope in the future, this might be solved. However, it is a good exercise to include a polygon method in this script. After defining a function that draws the polygon, the script uses it iteratively to create the grid.
I will try to publish and explain this as soon as possible. Also, I think that this and some other commands can be a plug-in in the future. There are many lunchbox plug-ins out there. But why not I shouldn’t code my own version.

# Draw centered hexagonal grid
# 25.07.2017 www.designcoding.net - Tugrul Yazar
import rhinoscriptsyntax as rs
import math
hexGridCenter = rs.GetPoint("Specify center point")
hexGridExtend = rs.GetInteger("Enter the number of radial levels", 3, 2)
hexGridClSize = rs.GetReal("Edge size of hexagons", 1.0)
hexGridCAngle = rs.GetReal("Rotation angle of hexagons", 0.0)
edges = 6
rs.AddPoint(hexGridCenter)
hexGrid = []
pythagoras = 2 * math.sqrt((hexGridClSize * hexGridClSize) - ((hexGridClSize / 2) * (hexGridClSize / 2)))
def polygon(center,edges,size,angle):
tempCircle = rs.AddCircle(center, size)
tempPoints = rs.DivideCurve(tempCircle, edges, create_points=False, return_points=True)
tempPoints.append(tempPoints[0])
tempHexago = rs.AddPolyline(tempPoints)
tempReturn = rs.RotateObject(tempHexago, center, angle, axis=None, copy=False)
rs.DeleteObject(tempCircle)
return tempReturn
for i in range(0, hexGridExtend):
tempSize = pythagoras * (i + 1)
dut = polygon(hexGridCenter, edges, tempSize, 30 + hexGridCAngle)
temp = rs.DivideCurve(dut, (i+1) * edges, create_points=False, return_points=True)
rs.DeleteObject(dut)
hexGrid.extend(temp)
for i in range(0, len(hexGrid)):
polygon(hexGrid[i], edges, hexGridClSize, hexGridCAngle)
rs.AddPoint(hexGrid[i])

Python file (PY)Download

Cite this post

Yazar, T. (2017, July 25). Hexagonal grid with Rhino Python. designcoding. Retrieved August 24, 2026, from https://www.designcoding.net/hexagonal-grid-with-rhino-python/

Related Posts

Waterbomb Tessellation

January 23, 2013

It all started with my new passion for origami tessellations, not much of origami, but the tessellation part. I was too lazy to fold it physically, nor model them using an engine such as Kangaroo. That would also be very unnecessary (and yes, very boring) to simulate a folding effort on the computer unless we lose our connection with the real world. Instead, I tried to look at a much more abstract, silly, and basic part of it; the creasing…

Vector Fields

December 28, 2012

Back to the basics. I finally had time to test the vector fields components in Grasshopper. It was a couple of updates ago, a new tool group emerged in the vector tab, introducing different types of vector fields to users. Then, these fields could be merged to form more complex effects. However, I created a very simple example of how we can use those components to distort a system (such as a regular tessellation).  Using attractor forces (usually in geometric…

Hexagonal Star Lattice

December 18, 2023

Here are the variations of classical six-pointed star patterns generated by Grasshopper. Generally, you can see these patterns under the title “Islamic patterns” because they are frequent in the decorations of mosques and palaces. I studied these patterns in Grasshopper earlier in these posts. I always find this an interesting geometry exercise. This time, my main goal was to develop a useful code only with the native Grasshopper components that create laser-cut-ready products of hexagonal star lattice. Thus, I made…

Revisiting RhinoScript

July 19, 2013

Recently, I returned to old fashion RhinoScripts in order to recapture its idea and functionalities again. After almost 10 years, this is my first experiment on creating a custom function that draws hexagonal grids. I tried to implement a fast process for it, however, there could be much faster ones. This script focuses on using functions, variables, and object arrays. I’ll continue to make more of these simple exercises and revisit some of the older studies on this blog page…

Parquet Deformation of Star Patterns

February 3, 2012

This is another starting point for pattern generation study in a dataflow environment. I tried to implement the parquet deformation of Islamic patterns in Grasshopper. I studied Hankin’s method of Islamic Pattern generation. Then I tried to simulate his process beginning with basic regular tiling (regular hexagonal tessellation). Craig S. Kaplan (here) explains this and other methods in his dissertation. A Simple Foundation We have already experienced the result of exploding any hexagonal grid, shifting its points with the help…

  • Chapters

    • Algorithms
    • Discourses
    • Fabrications
    • Studios
  • Explore

    • All Keywords
    • Table of Contents
    • Monthly Archive
    • #grasshopper
    • #linear-algebra
    • #vector
    • #parametric-curve
    • #tutorial
    • #polyhedra
    • #bezier-curve
    • #pattern
    • #simulation
    • #fourier
    • #fractal
    • #rhinoceros
    • #deformation
    • #design-education
    • #dual
    • #art
    • #design-object
    • #image-sampler
    • #growth
    • #vector-field
  • Search

  • Support designcoding!

  • Enjoying designcoding? Support me on Patreon to keep it growing. Thank you!

  • copyright 2026 designcoding.net | about | privacy policy | end user license agreement