Control Spacing of circles in Hex Grid

I am trying to create a perf pattern with staggered circles in it. I created a hex grid to make them staggered, but how do I control the distance between them?

Hi @courteneykemp,

The distance between your circles corresponds to radius of the inscribed circle of each hexagon cell minus the circle radius times 2!

what if the radius of my circle is .094" and I want the spacing to be .188" apart? how can I control that spacing manually?

Has anyone suggested to you yet that posting your actual GH file with internalized geometry (not just a screen shot) is the best way to get answers? It makes it so much easier for everyone.

CPP1 (24.6 KB) CPP1 7-15.3dm (51.9 KB)

Sorry. Thanks for reminding me to do that. Hope this helps.
The one on the left is pretty much what I’m wanting except id like the circles to be staggered with controlled distance between circles

R6 strikes again:


Given your screen shot of the code, I can fix it for R5 but can’t see your Crv from the Rhino file. Taking a wild guess, I created a line from the origin 50 units long in the X direction…

  1. For forum questions, it really helps if you internalize your geometry instead of referring to a Rhino file, especially when the geometry is extremely simple.
  2. Even better than internalized geometry is to use GH to create the geometry when possible, thus making it parametric.

Moving on… I see no reason to use Map Srf here unless your input curve is not a straight line?

  • For one thing, you can create the HexGrid in a vertical plane (XZ?) in the first place instead of mapping it from XY to XZ.
  • Second, as written, there is no guarantee that your ‘Target Surface’ has the same proportions as the HexGrid, and if it doesn’t, the hexagons will be distorted.

Referring to this portion of your model:


  1. There is no need to use PCen (Polygon Center) since you already have the center points from HexGrid.
  2. There is no need to “create plane normal to surface at cell center” since the ‘F’ output of EvalSrf gives you that already.

On curved surfaces, sometimes Circle CNR can be helpful, though I see no reason in this case:

This is getting to be a very long winded answer… I’m hesitant to refactor your code without knowing more about your input curve?

P.S. Playing with a curved input instead of a straight line, though both reveal a UV flip issue that is not at all intuitive for beginners!!

1 Like

Oh no, this is a duplicate thread?

The following doesn’t answer the question about spacing yet, but without your input curve, it’s a great example of possibly wasting time answering the wrong question:

CPP1 (27.7 KB)

Changing the ‘S’ input to HexGrid has no effect on the outcome because the result is determined by the length of the input curve. I hacked a Python SwapUV component (using ‘Transpose’); UV is a painful subject recently so to see why I did it, skip it and see what happens.

Unfortunately, radius of the circles is not proportional to hexagons in this model, as they are scaled by the length of the input curve. You could do the circles before Map Srf:

CPP1 (34.6 KB)

Or maybe you don’t need Map Srf at all?

1 Like

I am just using an 18" long straight curve and the panel is 24" in height… I need .094" diameter circles that are .188" apart. Does that help? Sorry, I am very new to this

So you don’t need Map Srf at all. That’s what I figured… :man_facepalming:

CPP1 (30.3 KB)

P.S. I didn’t actually cut the holes in the surface but you have three options:

  1. Boundary Surface using the perimeter curve and circles; this is often the best option for planar surfaces, but will be extremely slow for ~14,000 circles in this case!.
  2. SrfSpilt is probably even slower. Both might fail before they finish.
  3. Bake the surface and circles to Rhino and cut the holes there.

I already mentioned this old thread in your duplicate thread:

Some of it is irrelevant for planar surfaces but there is a discussion of option #3 (bake and cut in Rhino) showing it can be MUCH FASTER than Grasshopper.

Oh, there is a fourth option: cut holes in a panel that is ~1/10th the size (1/10th the number of holes!) and then copy/move it nine times.

1 Like

This is very helpful! one last question: how/where can I set a boundary that the hex grid cannot go beyond?

You can’t. I used manual slider settings with feedback from the “distance between centers” panel for spacing, then used Vec2Pt to move and realign the HexGrid and circles (default alignment is sub-optimal), and finally visual inspection to adjust the ‘Ex’ and ‘Ey’ inputs to HexGrid to match the rectangle size. You could do some math to calculate those values but I didn’t have time for that.

That’s okay. This is working great! Thank you so much!! (13.8 KB)

If I use this mapping, is there a way to control the spacing of the circles on here?

As I understand it, there are two basic parts to this question:

  1. Distance between centers?
  2. How many rows and columns can fit on a given rectangle? (for a given distance between centers)

Part 1 is basic geometry, and I’m pretty sure someone mentioned this already:


This is some GH that illustrates the “Qualities of a 30-60-90 Triangle”. Blue lines are the polygon’s radius (the ‘S’ input to HexGrid). White lines are half the distance between centers in a HexGrid. In other words, the distance between center points is half the radius times the square root of three times two. Or simply radius * √3 .

For radius = 2 as shown, distance between center points in a HexGrid is 3.4641.

The rest of the code addresses Part 2: How many rows and columns can fit on a given rectangle? As you can see by changing the ‘count’ slider, the ‘col/row average’ is useless because it changes constantly (can you see why?).

CPP1 (23.6 KB)

What remains constant, however, is:

  • vertical (Y) distance between rows = distance between center points.
  • horizontal (X) distance between columns is […] (another 30-60-90 triangle).
    (CORRECTION: In a rush to get out the door, I posted wrong information - sorry!
    Should be:

    horizontal (X) distance between columns is (distance between center points / 2) * √3
    OR… ((radius * √3) / 2) * √3.

The edges are a different matter but that’s all I have time for today. You have all the information needed to answer your questions. Think it though!

P.S. Have you tried yet to cut ~14,000 holes in your 18" X 24" surface? (using the code I posted yesterday) Good luck with that.

P.P.S. My plans today were changed by someone else… so here are more hints. Working backward from this to calculating ‘col count’ and ‘row count’ based on radius (HexGrid “Size”) and target rectangle size are left undone. But very close!

CPP1 (24.3 KB)

Well, this is almost the “Full Monty”. If it still doesn’t work for @courteneykemp, maybe others will find it useful or amusing. Two features that I believe Courteney would like to see are not implemented (yet, but don’t hold your breath for me to do them):

  1. To specify ‘distance between centers’ and derive HexGrid ‘radius’ from it, rather than the other way around as this code does.
  2. Center the grid of hexagons/circles on the rectangular panel? This code orients the grid to the bottom left corner.

Inputs are ‘X Size’ and ‘Y Size’ of the rectangle, ‘radius’ of the HexGrid cells and ‘diameter’ of the circles.

CPP1 (22.2 KB)

1 Like