知識がなくても始められる、AIと共にある豊かな毎日。
3D Printer

OpenSCAD LLM Workflow 2026: Writing Code CAD with ChatGPT and Claude

swiftwand

OpenSCAD is CAD you drive with code instead of a mouse. The official tagline calls it “The Programmers Solid 3D CAD Modeller”: you write dimensions and operations in a script, and the software compiles them into solids, a 3D compiler in practice. In 2026 that property, shape-as-code, has taken on new weight, because code is exactly what LLMs like ChatGPT and Claude can write.

Without any dedicated Text-to-CAD service, you can ask the chat AI you already pay for: “an OpenSCAD bracket, 60 mm outer diameter, four M4 holes,” and working code comes back. Free open-source OpenSCAD plus an LLM you already have is probably the cheapest possible entrance to generative AI for functional parts.

This article covers the code-CAD-plus-LLM path in practice: the prompt and verification patterns that make it work, OpenSCAD’s structural limit (mesh output), and CadQuery, the step up when you outgrow that limit. For the dedicated-service side, see the AI CAD copilot comparison.

忍者AdMax

The Third Road: Writing Shapes as Code

There are three roads to AI-assisted functional parts. Road one: drive GUI CAD by hand as always. Road two: have a Text-to-CAD service like Zoo generate from prompts. Road three: have a general-purpose LLM write code-CAD scripts. The third road’s strength is that the part’s recipe arrives as human-readable text from the start: diffable in version control, dimensions as named variables, fixes as one-line edits. It naively reproduces what Text-to-CAD services do internally, generating the procedure that builds the shape, using commodity tools.

The weakness, stated up front: an LLM writes syntactically correct code without guaranteeing spatial correctness, whether parts interfere, whether the hole landed where intended. Every generated script gets rendered, eyeballed, and measured. Whether the speed net of that verification is still worth it is the decision criterion for this road. Code-built shapes long predate generative AI; programmers have solved repetitive parts and size runs with scripts for decades. What changed is the writer: a shortcut once reserved for people who code became a shortcut for people who can state requirements in plain language. And for anyone already subscribed to an LLM, the marginal cost is zero with no free-tier meter anxiety.

What OpenSCAD Is

OpenSCAD is free software under GPL v2 for Linux, Windows, and Mac. The design philosophy is uncompromising: there is no interactive modeling. You write a script, OpenSCAD interprets it and renders the solid, exactly the 3D-compiler structure the project itself describes. Shapes are built with CSG, constructive solid geometry: primitives like cubes and cylinders combined through union, difference, and intersection. “Subtract four cylinders from a disc to get a bolt plate” is a thought that maps one-to-one onto code, which is why machine parts fit so well. Artistic freeform surfaces do not; the project is upfront that its lane is machine parts and parametric designs.

No interactive modeler sounds like a defect and is actually the source of consistency: no unreadable mouse history exists, every decision about the part persists as lines of code, and comments plus diffs tell who changed which dimension and why. For design reproducibility it is among the most principled software in CAD. The rigor cashes out as durability: a project is one text file, backup is copy, recovery is diff, and there is no “only opens in version X” hostage situation. For hobby work that pauses and resumes across years, that robustness matters. CSG also retrains your eye: most machine parts decompose into sums and differences of primitives, plate as box, boss as added cylinder, hole as subtracted cylinder. Anything you can decompose that way, you can explain aloud, and anything you can explain aloud you can hand to an LLM. For LLMs the language is ideal: compact spec, enormous public corpus of examples, stable syntax. Weathered, documented, and abundant, the perfect target for machine-written code.

Getting an LLM to Write OpenSCAD: Prompt and Verification Patterns

The prompt template matches Text-to-CAD: part name, governing dimensions, feature quantities. The code-CAD-specific addition: explicitly ask for dimensions as variables. One sentence, “define all dimensions as variables at the top,” transforms the reusability of what comes back. Any chat AI competent at code clears the bar for this job. A second practical trick: state the part’s job in one line. “Mounts under a shelf, carries about 2 kg from above” nudges the LLM toward sane wall thicknesses and hole placement. Human verification still owns the final call, but a better first draft cuts the round trips.

Here is the level of code an LLM returns for a 60 mm disc bracket, 6 mm thick, with four through-holes:

// Disc bracket: dimensions as variables
d_outer = 60;  // outer diameter, mm
t = 6;         // thickness, mm
d_hole = 4.5;  // through-hole diameter, mm (M4 with clearance)
r_pitch = 22;  // hole pitch-circle radius, mm

difference() {
  cylinder(h = t, d = d_outer, $fn = 128);
  for (a = [0 : 90 : 270])
    rotate([0, 0, a])
      translate([r_pitch, 0, -1])
        cylinder(h = t + 2, d = d_hole, $fn = 64);
}

It reads aloud: make a cylinder, subtract four smaller cylinders rotated in 90-degree steps and translated onto the pitch circle. Rewrite the header variables and outer diameter or hole size changes instantly; that is what holding a part parametrically in code means.

Fix the verification ritual at three stages. Preview and eyeball the whole shape. Measure the dimensions you specified, here the outer diameter and pitch circle. Then change one variable, re-render, and confirm the shape follows. Passing the third test promotes the code from one-off to template. That variable-change test earns its emphasis: LLM code often looks parameterized while a raw number hides inside, say the hole positions computed with a hard-coded half of the outer diameter. Change the diameter variable and the holes stay behind, the shape breaks, and you have found a hidden dependency; tell the LLM to derive that number from the variable and it will. Tests raising design quality is the same story as software.

Known failure patterns save time too. Most common: vague position words, “holes near the edge, evenly spaced-ish,” cured by explicit numbers. Second: one-shot orders for complex parts collapse; split them, first just the base plate, then add the mounting ears, stacking blocks with a visual check between steps, the same small-loop discipline that works with all coding assistants. When errors appear, paste them straight back; OpenSCAD errors carry line numbers and LLMs self-correct with high accuracy. Naming variables is also design thinking: separating d_hole from r_pitch documents which dimension answers to which requirement, the same discipline as naming constraints in GUI CAD, except code forces it.

The Limit: Output Is Mesh, Not STEP

OpenSCAD has one structural ceiling. Per the official manual, 3D export formats are mesh-class: STL, OFF, AMF, 3MF, with the application itself warning that AMF is deprecated in favor of 3MF. There is no STEP export; the internal representation is mesh-based, and parametric information does not survive rendering into the geometry file.

Day to day, the practical knob is curve resolution. The $fn seen in the sample sets how many facets approximate a circle: too low and cylinders print as visible polygons, needlessly high and previews and files bloat. Fine facets on visible and mating surfaces, coarse inside, treating mesh resolution as a design decision is the code-CAD way. The meaning of the mesh ceiling is exactly the mesh-versus-B-Rep argument from the Text-to-CAD guide. If you print your own parts, STL ends the story, because editability lives in the .scad file: change code, re-render. The pain arrives when the artifact leaves your desk, a machining quote, a collaboration with a mechanical engineer, an assembly in another CAD; the moment someone asks for STEP, OpenSCAD alone is stuck. Code as asset, mesh as only exit: use it with that asymmetry in view and it remains first-rate. That said, audit honestly how often you are asked for STEP: jigs, organizers, repair parts, the daily diet of a home printer, all end at STL. Knowing a limit and refusing a tool over it are different things; bank experience in the free environment and shop for the next tool the day STEP actually knocks.

CadQuery: Python, B-Rep, and STEP Export

The step over that wall is CadQuery, an Apache 2.0 open-source parametric CAD framework in Python, built on the OCCT kernel, Open CASCADE Technology, the same lineage as commercial mechanical CAD. Code in, B-Rep out, and per the official docs it exports the lossless CAD formats STEP and DXF alongside STL and 3MF.

Python matters in practice: it is the language LLMs write best, and dimension tables, BOM generation, and file plumbing can live in the same script as the geometry. With no GUI in the way, server-side generation of part families, the same idea as the API automation in Zoo Text-to-CAD in Practice, works in a plain Python environment. Learning order: OpenSCAD first, CadQuery when needed, looks slow and is fast. OpenSCAD’s tiny spec isolates the essential habits, decomposition and variables; CadQuery adds B-Rep concepts, workplanes, fillets, edge selection, more power for more study. The variables habit transfers wholesale. The split: self-printed parts at minimal learning cost, OpenSCAD; STEP hand-offs or Python integration, CadQuery.

Where Code CAD Sits Next to Zoo and GUI CAD

ToolCostOutputBest for
OpenSCAD + LLMFree (LLM you already have)Mesh (STL / 3MF)Self-use functional parts, size runs
CadQuery + LLMFree (same)B-Rep (STEP) + meshParts leaving your desk, Python pipelines
Zoo (KCL)Free tier + meteredB-Rep (STEP + KCL)Buying generation quality and an integrated studio
GUI CADFree to subscriptionTool-dependentInteractive exploration, complex assemblies

Read the table along two hidden axes: where the code lives and where the compute lives. OpenSCAD and CadQuery keep both local: offline-safe, no metering anxiety, everything under your control. Zoo returns the code (KCL) but computes in the cloud, a distinction that surfaces in confidentiality and offline requirements no feature chart shows. This is a trade-off table, not a ranking; Zoo buys model quality and an integrated environment, code CAD buys zero cost and freedom. The common 2026 route: build the habits on OpenSCAD, expand into Zoo or CadQuery as needs appear. Code CAD is also the cheapest classroom for the skill every AI design tool demands, verbalizing requirements, the thread running through this whole series.

Summary: Your Existing LLM Turns a Free CAD into a Weapon

OpenSCAD plus an LLM is unglamorous and outrageously cost-effective. OpenSCAD: GPL v2, free, a 3D compiler with CSG at its heart, strongest on machine parts, and an ideal LLM target thanks to its small, weathered spec and huge example corpus. The prompt pattern: part, dimensions, quantities, plus “dimensions as variables.” Verification: eyeball, measure, then the variable-change test, with errors pasted back for self-correction. The ceiling: mesh-only export, STL and 3MF, no STEP, though your editability lives in the .scad file. The way past it: CadQuery, Apache 2.0, OCCT, Python, STEP out. And the placement: local code and local compute versus Zoo’s cloud engine, chosen by confidentiality, connectivity, and budget.

One more property deserves the last word: OpenSCAD plus an LLM cannot be discontinued. A GPL interpreter and a text file on your disk will regenerate the same part in ten years, no service shutdown in the loop. For repair parts and jigs, the things you need again long after you forgot them, that persistence is worth as much as speed. Install OpenSCAD, order one part from your LLM, change a variable, and watch the shape follow. Owning designs as text starts there. The full landscape: AI 3D design complete guide.

ブラウザだけでできる本格的なAI画像生成【ConoHa AI Canvas】
ABOUT ME
swiftwand
swiftwand
AIを使って、毎日の生活をもっと快適にするアイデアや将来像を発信しています。 初心者にもわかりやすく、すぐに取り入れられる実践的な情報をお届けします。 Sharing ideas and visions for a better daily life with AI. Practical tips that anyone can start using right away.
記事URLをコピーしました