The parametric part prompt for OpenSCAD
Describe a functional part with real measurements and get back OpenSCAD with every dimension as a named variable, a clearance knob, and FDM rules baked in.
- Use case
- CAD & functional prints
- Works with
- Claude, GPT-class
Write an OpenSCAD model for this part: {what it is and what it attaches to
or holds}.
Measured dimensions: {list every dimension you measured, and mark which
ones are exact fits against another object}.
Requirements:
- Every dimension I gave you becomes a named variable at the top of the
file, with a comment saying what it controls in plain language.
- Add a `clearance` variable (default 0.2) and apply it to every dimension
I marked as a fit. Fits get looser when clearance goes up.
- Design for FDM: pick the flattest face as the print bed face, avoid
overhangs past 45 degrees, and tell me if the shape forces one. Minimum
wall thickness 1.2mm.
- Before the code: list any dimension that is ambiguous or that you need
and I did not give you. Do not invent measurements.
- After the code: tell me which variable to change if the fit comes out
too tight, and which if it is too loose.
Brackets, clips, spacers, the shim that holds the thing to the other thing: the parts you need are the parts nobody uploaded. OpenSCAD is the right tool because it is text, and text is the one thing these models are actually good at. But ask casually and you get a script full of magic numbers that you cannot adjust when the first print comes out 0.4mm too snug.
This prompt front-loads the two facts every functional print lives or dies on: which dimensions are fits, and what happens when the fit is wrong.
Why it works
- Marking fits is the whole game. A hole that clears a screw and a hole that grips a bearing are different holes. Telling the model which is which is information it cannot guess from a measurement.
- The
clearancevariable turns reprints into one-line edits. First print too tight? Bump one number, recompile, reprint. Without it you are hunting through the code deciding which of nine numbers encodes the fit. - “Do not invent measurements” is there because models will absolutely fabricate the diameter of a 2020 extrusion slot rather than ask. The pre-code question list catches the gap while it is still cheap.
What good output looks like
A file where the top fifteen lines are variables you understand and the geometry below them is something you never need to touch. My test: could I hand the file to someone with the same printer and a slightly different measurement, and could they fix it without reading the geometry? If yes, it is parametric. If no, it is a magic-number script with extra steps.
Where it works (and doesn’t)
Claude and GPT-class models write clean OpenSCAD. Local models under 30B produce code that compiles but drifts from the spec (walls too thin, clearance applied to the wrong dimensions), and checking their geometry takes longer than writing it. Complex curved surfaces are also out; this is a bracket-and-box prompt, not a sculpting tool.
Print the first one in draft quality. The prompt gets the code right; the calipers get the part right.