import rhinoscriptsyntax as rs
import math

def speaker_grid():
    center = rs.GetPoint("Center of the speaker grid")
    if center is None: return

    radius = rs.GetReal("Overall grid radius", 50.0)
    if radius is None: return

    rings = rs.GetInteger("Number of rings", 6, 1, 50)
    if rings is None: return

    hole_radius = rs.GetReal("Hole radius", 2.0)
    if hole_radius is None: return

    plane = rs.WorldXYPlane()
    plane.Origin = center
    rs.AddCircle(plane, hole_radius)

    for ring in range(1, rings + 1):
        ring_radius = (radius / rings) * ring
        hole_count = ring * 6
        for i in range(hole_count):
            angle = (2 * math.pi / hole_count) * i
            x = center.X + ring_radius * math.cos(angle)
            y = center.Y + ring_radius * math.sin(angle)
            hole_plane = rs.MovePlane(plane, [x, y, center.Z])
            rs.AddCircle(hole_plane, hole_radius)

speaker_grid()
