Scripting · Tutorial

Vibe Coding your Tools in Rhino

Chat with an AI assistant connected to Rhino through RhinoMCP to prototype a circular speaker-grid pattern live, then turn the finished script into a reusable Rhino command.

25 minRhino 9 for Windows / MacIntermediate

Rhino connects to an AI assistant through the Model Context Protocol (MCP) with the native RhinoMCP and mcpstart commands. Once connected, you can describe the geometry you want in plain language, watch the assistant build it live in your Rhino session, and refine it by continuing the conversation instead of rewriting code by hand. In this tutorial, we’ll use that conversation to prototype a circular grid of holes, like a speaker grille, and then turn the finished script into a real, reusable SpeakerGrid command with its own command-line prompts.

What You’ll Need

  • Rhino 9 for Windows or Mac.
  • An MCP-capable AI chat client, such as Claude Desktop, that can connect to a local MCP server.
  • No Python knowledge required. The assistant writes and edits the script for you; some familiarity with Python is helpful, but not necessary, if you want to read along.

Connect Rhino to an AI Assistant

NOTE TO SELF: This whole section needs revision next week (Sep 21 2026), once the panel is native to Rhino.

  1. In your AI chat client’s MCP configuration, add an entry that starts the RhinoMCP server. For Claude Desktop, this goes in its configuration file:
1
2
3
4
5
6
7
8
9
{
  "mcpServers": {
    "rhino": {
      "command": "uvx",
      "args": ["rhinomcp@latest"],
      "env": { "RHINO_MCP_HOST": "127.0.0.1" }
    }
  }
}
  1. Restart your AI chat client so it picks up the new server.
  2. Back in Rhino, run the McpStart command to open the connection. This will open the AI panel. Your AI chat client can now see and control the active Rhino session.

NOTE TO SELF: Add an image of the RhinoMCP panel here next week (Sep 21 2026)

This Gives the Assistant Real Control
Once connected, the assistant can create, modify, and delete geometry, and run arbitrary Python in your Rhino session. Only connect it to a file you don’t mind an AI editing, and run mcpstart again to close the bridge, or quit the chat client, once you’re done experimenting.

Prototype the Grid in Conversation

  1. With the bridge running, in the AI Panel, describe the pattern you’re after instead of writing it from scratch:

    Write RhinoScript-Python that draws a circular grid of small circles around a center point, arranged in concentric rings, like the holes in a speaker grille. Run it in Rhino so I can see it.

  2. The assistant writes the script and calls RhinoMCP ’s execute_rhinoscript_python_code tool, which runs the code directly in your open Rhino document. The grille pattern appears in the viewport immediately, so you can keep iterating conversationally:

    Space the rings further apart near the center, and make the holes a bit smaller. Each reply re-runs an updated script against the live model.

A speaker grid created with radius: 50, rings: 6 and hole radius: 4. The circles look randomly placed, which is not desired.

A speaker grid created with radius: 50, rings: 6 and hole radius: 4. The circles look randomly placed, which is not desired.

The Result Doesn't Hold Up
The circles don’t form clean rings. They look randomly scattered instead, because each ring’s hole count is derived independently from its circumference, so neighboring rings don’t line up into consistent spokes. Keep prompting RhinoMCP to fix the pattern rather than patching the script by hand:

  1. Tell the assistant what’s wrong and how you want it fixed:

    The holes look randomly scattered instead of forming clean rings. Update the script so each additional ring adds exactly 6 more circles than the ring before it, keeping them evenly spaced around the circle.

  2. Let RhinoMCP run the updated script and check the result in the viewport.

  3. Run it again with the same values as before: center 0, radius 50, default rings, hole radius 4. Confirm the holes now line up into even radial spokes instead of a scattered pattern.

    The same values, now with 6 more circles added per ring. Now the radial spokes are well aligned.

    The same values, now with 6 more circles added per ring. Now the radial spokes are well aligned.

  4. The assistant’s modified script should now look close to this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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()
  1. Download the fixed script: speaker_grid.py

Save the Working Script

Once you’re happy with the result, save the script you downloaded above to disk somewhere permanent, for example Documents\Scripts\speaker_grid.py. You’ll point to it when turning the script into a command in the next step.

Checking the Script Yourself
Open it with the EditPythonScript command to read through it, adjust it, or press to test-run it before wiring it up as a command.

Turn the Script into a Command

A script only becomes a command you can type at the command line once it’s linked to an alias.

  1. Run the Options command and open the Aliases page.

  2. Click New, and set:

    Alias Command macro
    SpeakerGrid ! _-RunPythonScript "Documents\Scripts\speaker_grid.py"
  3. Close the Options dialog. Typing SpeakerGrid now runs your script exactly like a built-in command, prompts and all, any time, with no AI connection required.

From Circles to a Real Grille
The command creates flat circles as construction geometry. Select the outer boundary and holes, run ExtrudeCrv on a panel, then BooleanDifference the extruded holes out of it to get a real perforated speaker grille.

Add a Toolbar Icon

Typing SpeakerGrid works, but a clickable icon is faster to reach for a command you use often.

  1. Go to the Window menu, click Toolbars, and right-click any gray area of a toolbar. Choose New Toolbar Button….

  2. Select Empty Button, click Next, choose Image only for the button appearance, and click Finish. A blank button appears on the toolbar.

  3. Press + right-click the new button to open the Button Editor.

  4. Under Tooltip, enter Speaker Grid. Under Command, enter the same macro you used for the alias:

    ! _-RunPythonScript "Documents\Scripts\speaker_grid.py"
    
  5. Click the arrow next to one of the image squares in the top-right corner of the editor to open the built-in Image Editor. Draw an icon with the built-in tools, or click the Gear icon, then File > Import…, to bring in an SVG you’ve made instead.

  6. Click OK to close the Image Editor, then OK again to close the Button Editor.

Click the new button to test it — it walks through the same prompts as typing SpeakerGrid at the command line.

Keep Custom Toolbars Safe

Buttons you add to Rhino’s default toolbar file get wiped out on a reinstall or a Reset. Before adding more than one or two, create your own RUI file first ( Options

Appearance > Toolbars, then + > New) and build your toolbar there instead. See Customize Your Toolbars for a closer look at the Button Editor, including drawing button icons from scratch.

Where to Go from Here

  • Package speaker_grid.py and a handful of related scripts as an installable plugin — see How to Use Scripts and Plugins for packaging and distribution options.
  • Remember to close the mcpstart bridge when you’re not actively using it — there’s no reason to leave an AI assistant with live code execution access to Rhino running in the background.