LLM-RAG Generator Spiral Staircase (Grasshopper C# | 00–09 STEP pipeline)
Spiral Staircase / General CAD LLM-RAG Generator (Grasshopper C# | 00–09 STEP pipeline) is a production-minded parametric CAD system where prompts don’t “draw” — they author structured parameters (CFG) that reliably drive a clean, editable Brep-based staircase assembly.
You get a repeatable loop:
Prompt → CFG/SFG overrides → Helix skeleton → Treads → Core/Stringers → Rail/Guard → Landings → Detailing → QA/Export
It’s built to be:
- Visibly responsive: small prompt changes can push turns, step count, radii, tread/rail density, landing patterns, etc.
- Stable in Grasshopper: hard caps on segmentation + time budgets.
- Fabrication-friendly: solids produced primarily via capped extrusions (boolean-light).
- Reusable: swap the CFG key set + RAG corpus and you’ve got a new parametric product line.
Bonus: the annoying RhinoCommon mismatch bug is handled —
'Brep' does not contain a definition for 'CreateFromExtrusion'
is fixed by using Extrusion.Create(...) (with solid caps) and a robust fallback to Surface.CreateExtrusion(...) + CapPlanarHoles(...) (patched in STEP_03 + STEP_06).
README.txt contents (full)
(Identical to the downloadable file.)
WICKERSON STUDIOS — SPIRAL STAIRCASE / GENERAL CAD LLM-RAG PIPELINE
README.txt (vCAD_RAG1.0 — Grasshopper C# Script Series 00_STEP … 09_STEP)
================================================================================
WHAT THIS IS
------------
This is a 10-node Grasshopper (C# Script) “LLM-RAG CAD generator” pipeline that
builds a high-LOD spiral staircase assembly from a text/image prompt.
The series is designed to feel like a production CAD pipeline:
00_STEP INIT / Master CFG+SFG / EngineState (JSON)
01b_STEP LLM prompting (OpenAI Responses API) -> CFG/SFG overrides + RAG docs
02_STEP Helix spine + step planes (parametric skeleton)
03_STEP Treads (solid wedge steps) ✅ includes safe extrusion fix
04_STEP Stringers + center core (structural solids)
05_STEP Rail / guard / balusters (safety/handrail geometry)
06_STEP Landings (platforms) ✅ includes safe extrusion fix
07_STEP Detailing pass (nosing, chamfers, fasteners, perforations)
08_STEP Assembly / tagging / drawing aids (leaders, labels, outlines)
09_STEP Export + QA (stats, sanity checks, baking helpers, OBJ/3DM stubs)
The core idea:
- The prompt DOES NOT directly “draw geometry.”
- Instead, the LLM returns a strict, structured set of *CFG keys* (numbers + enums)
that drive downstream geometry deterministically.
- The RAG corpus supplies precedent + style hints (e.g. stair types, materials,
code-driven proportions), and the LLM can rewrite/extend that corpus per prompt.
If you don’t provide an API key, the pipeline still works: it uses deterministic
fallback values so the Grasshopper definition is always runnable.
WHAT YOU GET
------------
- A repeatable “prompt -> parameters -> CAD” workflow (no black box mesh magic).
- High-LOD solids suitable for render, documentation, and fabrication prep.
- Hard performance caps (segment counts + time budgets) so GH recomputes stay sane.
- A reusable architecture for ANY parametric CAD generator (swap the CFG keys +
RAG corpus and you have a new product line).
WHY IT’S DIFFERENT (THE WICKERSON WAY)
--------------------------------------
Most “AI CAD” ideas stop at images. This system generates *editable geometry*
through a real CAD pipeline and a structured prompt interface.
You can:
- iterate quickly with prompts,
- keep geometry stable + boolean-safe,
- and still get clear, visible differences every run.
Quick pitch:
“A prompt-driven spiral staircase generator that outputs clean Breps,
plus a framework you can reuse for any parametric CAD product.”
SYSTEM REQUIREMENTS
-------------------
- Rhino 7 or Rhino 8 + Grasshopper
- C# Script component (Grasshopper built-in)
- Internet access ONLY for STEP_01b if using OpenAI
- Optional: An OpenAI API key (kept private; do NOT hardcode in GH files)
SECURITY / COST NOTE
--------------------
- STEP_01b calls https://api.openai.com/v1/responses when API_KEY is provided.
- API usage costs money. Keep prompts concise and use “cached signature” logic.
- Never share your API key in public GH files.
PIPELINE WIRING (HIGH LEVEL)
----------------------------
Every STEP passes forward a JSON string called STATE:
STATE_OUT -> STATE_IN
Suggested GH component names:
00_STEP_INIT
01b_STEP_LLM_CFG_SFG
02_STEP_HELIX_PLANES
03_STEP_TREADS
04_STEP_STRINGERS_CORE
05_STEP_RAIL_GUARD
06_STEP_LANDINGS
07_STEP_DETAILING
08_STEP_ASSEMBLY_TAGS
09_STEP_EXPORT_QA
The key wiring pattern:
00 STATE_OUT -> 01b STATE_IN -> 02 STATE_IN -> 03 STATE_IN -> ... -> 09 STATE_IN
02 StepPlanesOut -> 03 StepPlanesIn -> 06 StepPlanesIn -> (others)
02 StepAnglesOut -> 03 StepStartAngleDegIn -> 06 StepStartAngleDegIn
Run toggles:
- Put a boolean “Run” into each step.
- For stable iteration, only toggle the steps you need to recompute.
MASTER CFG (CANONICAL KEY SET FOR SPIRAL STAIRCASE)
---------------------------------------------------
Paste the CFG string into 00_STEP (cfg input) and/or allow 01b_STEP to override.
NOTE:
If your STEP_01b “ALLOWED keys” list is still bridge-specific, update that list to
match the staircase keys below so prompts visibly affect the geometry.
--- MASTER CFG (copy/paste) ---
brand=Wickerson Studios
project=Spiral Staircase LLM-RAG CAD Generator — vCAD_RAG1.0
cta=https://www.wickersonstudios.com
# units + tolerances
units=m
grid=1.0
snapTol=0.01
basePlane=WorldXY
# staircase drivers
direction=ccw # ccw | cw
stepCount=42
turns=1.25 # total revolutions
totalRiseM=3.15 # total vertical rise
riserH=0.075 # if set, can override stepCount in STEP_02 (optional)
treadW=0.90
nosing=0.02
outerRM=1.35
innerRM=0.15
stepThk=0.06
maxStepSeg=24 # polyline segments per wedge arc
# core / structure
coreType=center_column # center_column | none
coreRM=0.10
coreWallThk=0.02
stringerType=outer # outer | inner | double | none
stringerThk=0.03
stringerH=0.18
# rail / guard
railEnable=true
railH=0.95
railDia=0.04
balusterEnable=true
balusterDia=0.018
balusterSpacing=0.12
guardPanelEnable=false
guardPanelThk=0.010
# landings
landingEnable=true
landingAtBottom=true
landingAtTop=true
landingEveryN=0 # 0 disables intermediate landings; try 12 for every 12 steps
landingDepth=1.40
landingW=1.20
landingThk=0.08
maxLandings=8
# detailing (STEP_07)
chamferR=0.005
treadPerforate=false
treadPerfDia=0.018
treadPerfPitch=0.060
fasteners=false
fastenerDia=0.008
# performance caps
booleanBatch=8
timeBudgetSec=8
# RAG controls
ragEnable=true
ragTopK=6
ragMinScore=0.22
ragDiversity=0.35
# LLM controls (01b)
llmModel=gpt-5.2 # often hardcoded in 01b for safety/consistency
llmMaxOut=1400
llmTemp=0.25
MASTER SFG (STRUCTURED FOCUS GUIDANCE)
--------------------------------------
This is the “creative + intent” channeling text. It’s meant to be detailed and
CAD-facing. Paste into 00_STEP (sfg input) and/or allow 01b to rewrite/extend it.
--- MASTER SFG (copy/paste) ---
reference: High-LOD spiral stair precedents: industrial steel helix with crisp tread rhythm, center column + outer stringer, clean welded logic, code-like consistency. Emphasize strong silhouette and readable structural hierarchy (core -> stringer -> treads -> guard).
program: Interior stair assembly for architectural massing studies; fabricate-friendly solids; stable recompute in Grasshopper; clear handrail/guard components.
style: Engineering-forward, minimal, precise. Avoid noisy ornament unless prompted. Prioritize legibility: treads read as repeated wedge modules, rail reads as continuous curve with evenly spaced verticals.
massing: Helix spine sets the primary sweep; step planes sample along the helix. Treads are wedge solids (inner->outer radius) with a subtle nosing. Optional landings at top/bottom and code-like rise/run consistency.
facade: Guard/handrail is the “facade”: continuous top rail, vertical balusters, optional panel infill. Keep everything aligned to step planes and helix tangent for clean flow.
math: turns + stepCount control angular increment; totalRiseM controls vertical increment; radii control wedge geometry; spacing controls baluster density; timeBudget + segment caps keep recompute stable.
notes: Prompts should visibly affect: turns, stepCount, radii, treadW, rail style/density, landing pattern. Keep booleans conservative; prefer extrusions and capped solids for robustness.
PROMPTING (WHAT TO TYPE INTO 01b)
---------------------------------
Use 01b “Prompt” as the driver. Good prompts combine style + proportions + material.
Example prompts:
1) “Brutalist concrete spiral stair, thick treads, wide outer radius, minimal guard, heavy landings.”
2) “Lightweight industrial steel spiral, thin treads, dense balusters, tight inner core, 1.75 turns.”
3) “Museum stair: generous landings, elegant sweeping rail, low step rise, airy spacing.”
The point: your prompt should cause 01b to override CFG values like:
turns, stepCount, totalRiseM, outerRM, innerRM, treadW,
railEnable/balusterSpacing, landingEveryN, landingDepth/landingW, etc.
KNOWN FIXES (ALREADY PATCHED IN THIS CHAT)
------------------------------------------
If you saw this compile error:
'Brep' does not contain a definition for 'CreateFromExtrusion'
That is now fixed by replacing it with a safe helper:
Extrusion.Create(profile, height, cap:true) -> ToBrep()
fallback: Surface.CreateExtrusion(...) -> CapPlanarHoles(tol)
This patch is applied in:
- STEP_03 (Treads)
- STEP_06 (Landings)
TROUBLESHOOTING
---------------
1) Empty geometry outputs:
- Confirm upstream wires: StepPlanes + angle lists must match counts.
- Confirm Run=true and timeBudgetSec not too low.
2) Weird rotations:
- Your StepPlanes may not have consistent X/Y axes assumptions.
- Fix by reorienting planes from helix tangent + global axis in STEP_02.
3) Caps fail / invalid Breps:
- Increase snapTol slightly (0.02).
- Ensure innerRM < outerRM - treadW margin.
- Reduce maxStepSeg if the boundary self-intersects.
4) Performance:
- Lower stepCount, maxStepSeg, baluster density.
- Keep timeBudgetSec realistic (6–12 sec).
LICENSE / USE
-------------
Use this as a boilerplate for your own generators and products.
If you’re distributing, keep your OpenAI key out of the file.
WICKERSON STUDIOS
----------------
If you want the “full pack” version (all steps fully built, labeled, QA’d, and
with multiple staircase archetypes + prompt presets), publish it as a
Wickerson Studios download and iterate the CFG keys the way you like.
Site: https://www.wickersonstudios.com