ucsd-compfab2

Week 5 - Python and LLMs as Rhino Interfaces

Tuesday 10/27

Agenda

Review and Discuss

(20 min)

Handing Over the Design

We have been exploring successive ways to abstract design processes and use computation to produce form.

Week 1 was hand authored geometry. Week 2 was driven with parameters and sliders in Grasshopper. Week 3 explored data-driven form, where the designer chooses a mapping. Last week we set attractors and optimized towards seed points.

This week we are exploring Python (computer code) to author forms, LLMs to author that python code, and then LLMs with MCP to directly code and run code in Rhino.

Questions for today:

Before Class: Setup

Required (everyone): Rhino 8 with the Script Editor working. Try it out: enter the command ScriptEditor. (just like how we launch Grasshopper)

Optional (to follow along in part 4):

I will demo paid options. Nothing today requires paid models.

Demos

1. Programming Interfaces to Rhino and Grasshopper

(30 min) Demo and Hands-on.

So far we have used Grasshopper to program Rhino. Python provides another path. This is what an LLM will write for you late today, so you need to be able to read it.

Rhino has a built in python interface. (As many other graphics softwares do—-Maya, Blender, etc.).

Example files:

2. LLMs Generate Python

This example works with your preferred LLM, either local (on a laptop, if you run local models) or on a c loud provider. I will demonstrate it with TritonGPT, UCSD’s own on-campus model.

Starting Questions:

  1. Let’s try asking a chatbot for the same attractor screen, e.g.:

    “Write RhinoPython (rhinoscriptsyntax, Python 3, Rhino 8) that makes a 200 × 200 mm screen: a grid of circles whose radius goes from 1 to 6 mm based on distance to a point at (60, 140), with at least 2 mm between neighboring holes.”

  2. Paste into the Script Editor and run it. Did it run the first time? If not, paste the error back in and see what it does.
  3. Compare to the hand-written version from part 1, line by line. What did it assume you meant?
  4. Verify (the most important step of the day):
    • push the inputs to extremes (attractor at a corner, radius range 0.5–10)
    • closed curves? duplicates? minimum bridge width actually respected?
    • units: mm or inches?
  5. Now try a looser prompt, the kind that invites subtle mistakes:

    “Write a Rhino Python script that makes a 200 x 200 laser-cut screen. Fill it edge to edge with a grid of circular holes. The hole radius should go from 1 to 6 based on the distance to an attractor point at (60, 140). Keep at least 2 mm between neighboring holes. Use rhinoscriptsyntax.”

    It never says which way the radius should go, asks for “edge to edge”, and doesn’t mention units. Run the verification checklist on whatever comes back. Things to look for: holes hanging off the edge, bridges under 2 mm, duplicate circles, big holes where you wanted small ones, and no unit check.

  6. Ending Questions:
    • 🖐️ What approaches do you have for testing/verifying or better yet, understanding the output of generative models?
    • 🖐️ Where do you learn about how to do things when working with models to generate your code?

Example file:

3. Intro to MCP

What is Model Context Protocol (MCP)?

Key concepts:

Questions:

4. RhinoMCP

(20 minutes) DEMO. Only follow along in pairs if you have access to a model capable of MCP.

Using McNeel’s free Rhino MCP plugin:

  1. Build: prompt the agent to make the attractor screen directly in Rhino.
  2. Extend a student’s definition: take a week 4 Pattern Object and ask for a change — “add a second curve attractor,” “make it fit a 32 mm sill,” “put laser-ready curves on a ‘cut’ layer.”
  3. Same prompt, three runs: run one prompt three times. Compare. This mirrors the 3-instance test, but the variation is uncontrolled: is it parametric variation, or noise?
  4. Agent → fabrication prep: ask it to check a mesh for printability (naked edges, wall thickness, bed size), then confirm with Rhino’s own Check, ShowEdges, MeshRepair.

Tips:

5. Raven and Custom LLMs

Raven (free plan): “the AI for Rhino & Grasshopper.” Describe what you want and it works directly in Rhino and Grasshopper — modeling, editing, or building Grasshopper components — with no Python for you to read in between.

Custom LLMs

Discussion: whose patterns does each tool reproduce? (Picon on digital ornament; week 3’s “data as corpus.”)

Optional: Blender as an alternative to Rhino/GH

For anyone interested, Blender also has MCP interfaces. And we can try blender as an alternative to Rhino/GH. Everything we did today in Rhino has a Blender equivalent, Blender is free on every platform, and many of you have used it before:

Rhino / Grasshopper Blender
RhinoPython (rhinoscriptsyntax, Rhino.Geometry) Blender Python (bpy), in the Scripting workspace
Grasshopper Geometry Nodes
McNeel’s Rhino MCP plugin MCP for Blender (formerly BlenderMCP), free and open source

The likely MCP → Blender route (from the project’s README; check the repo directly for the current steps):

  1. Install Blender 3.0 or newer and the uv Python tool manager: brew install uv on Mac, winget install --id=astral-sh.uv -e on Windows. Use uv’s own installer, not pip install uv.
  2. Install the add-on (uvx mcp-for-blender install-addon, or download addon.py from the repo), then enable Interface: MCP for Blender in Edit → Preferences → Add-ons.
  3. In the 3D viewport press N, open the MCP for Blender tab, and start the server.
  4. Point an MCP client at it, e.g. Claude Desktop (Settings → Developer → Edit Config):
    { "mcpServers": { "blender": { "command": "uvx", "args": ["mcp-for-blender"] } } }
    

    Cursor, VS Code, Claude Code and others are documented in the README. Run only one client against it at a time.

  5. Prompt for the attractor screen: a 200 × 200 mm plate, 3.2 mm thick, with holes whose radius goes from 1 to 6 mm by distance to (60, 140) and at least 2 mm between them. Then ask it to describe what it built.

Things that are different in Blender

Midterm Work

Generative Hands-On

(20 minutes) individual.

Use one of the methods above (LLM to generate python, MCP to control Rhino, Raven, Blender and MCP/llm) to try to generate some element of your midterm project. Work in pairs if you prefer.

What works? What doesn’t?

We will share at the end of class.

Wrap-up: Midterm Check-In

Homework

Complete Midterm

Complete your midterm piece. Midterm Critique is in two weeks(Week 7). See Project 1. We will continue with other material next week.

If you use an LLM or other generative tool on the project, assemble this supplementary document:

AI Process Log

If you use AI tools for your midterm project, document the process in your sketchbook:

Reading 5: Compression, Averages, and Authorship

Read both:

  1. Chiang, T. “ChatGPT Is a Blurry JPEG of the Web.” The New Yorker, February 2023. (TK: link)
  2. Steyerl, H. “Mean Images.” New Left Review 140/141, 2023. (TK: link/PDF on Canvas)

Response prompt on Canvas.

DUE Monday 11/2 EOD. Post your response to the discussion forum. We’ll discuss it in Week 6.

References

Authorship, craft, and the black box

AI and architecture / design