Maker tech hub — AI · 3D print · Pi · ESP32 · plus the classic tech archive.

Free ESP32 kit · AI tools directory · Books · Archive

Article · Beginner · AI Tools

OpenSCAD Prompt Pack Preview (Free Patterns)

Five reusable prompts that output named parameters, not mystery STLs.

Written by

Avery J. Parker

IT veteran, maker educator, and author of Network Ninja, 3D Printing Mastery, and AI Workflow Mastery. Business IT: Diversified Tech Solutions.

Ask a language model for "an OpenSCAD box" and you usually get a file full of unexplained numbers. It renders, but you cannot resize it without reading every line. The fix is in the prompt: ask for named parameters, modules, and an assumptions list. Below are five reusable prompt patterns that do that. Copy them, fill in your part, and always check the result against your measurements.

What good OpenSCAD output looks like

  • All dimensions are variables at the top, with units in comments.
  • Customizer-ready. OpenSCAD's Customizer panel reads comments in a specific format: /* */ groups variables into tabs, and a trailing comment like // turns a number into a slider with min, step, and max. A /* */ section keeps internal values out of the panel.
  • Modules for repeated features such as screw holes or standoffs.
  • No guessed dimensions. Anything you did not provide is listed as an assumption.

Pattern 1: parametric part from measurements

Write OpenSCAD for the part below.
- Put every dimension in a named variable at the top, grouped with
  Customizer section comments, units in mm.
- Add Customizer slider ranges for the main dimensions.
- Use only the measurements I give. List anything missing under
  "Assumptions" and use clearly named variables for those values.
- Use modules for repeated features.
- Output one code block, then the assumptions list.

Part: (describe the part)
Measurements: (list your measured dimensions)

Pattern 2: refactor an existing file

Refactor this OpenSCAD file without changing the geometry.
- Replace every literal number with a named variable at the top.
- Name variables by purpose (wall_thickness, mount_hole_spacing),
  not by shape (a, b, x1).
- Extract repeated code into modules.
- After the code, list every original number and the variable that
  replaced it, so I can check nothing changed.

(paste file)

The mapping table at the end is the important part. It makes it easy to confirm the model did not quietly change a value.

Pattern 3: add print tolerances

Add fit tolerances to this OpenSCAD design.
- Add a variable "clearance" (default 0.2 mm) for sliding fits and
  "press_clearance" (default 0.1 mm) for press fits.
- Apply clearance only to features that mate with another part, and
  say in a comment which features you changed and why.
- Do not change outer dimensions.

(paste file)

Those defaults are just starting points. Real clearances depend on your printer, nozzle, material, and orientation, so print a small test piece and update the variables.

Pattern 4: enclosure with lid

Write a parametric OpenSCAD enclosure.
- Inputs as variables: inner length, width, height, wall thickness,
  corner radius, lid clearance, standoff positions and height,
  screw hole diameter.
- Generate the base and the lid as separate modules, with a variable
  to choose which one to render.
- Place standoffs from a list of  positions.
- Do not invent board dimensions or hole positions; leave them as
  variables with a comment saying to measure the board.

Pattern 5: review before printing

Review this OpenSCAD file for printability on an FDM printer with a
0.4 mm nozzle.
- Flag walls thinner than two line widths, unsupported overhangs past
  45 degrees, bridges that look long, and holes likely to print small.
- Suggest a print orientation and explain why.
- Do not rewrite the file. Give a numbered list of issues with the
  line or variable involved.

(paste file)

How to use these well

  1. Measure first. The prompts work best with real numbers from calipers or a datasheet.
  2. Render and inspect. Open the result in OpenSCAD, check the Customizer panel, and preview with different values to make sure the parameters really drive the geometry.
  3. Check assumptions. Every item in the assumptions list is a value you need to confirm.
  4. Print a test section of anything with tight fits before printing the whole part.
  5. Save prompts that work in a text file or repository so you can reuse them.

Common mistakes

  • Accepting code that renders without checking dimensions. A model can produce valid OpenSCAD with the wrong size.
  • Asking for too much in one prompt. Build the base shape, then add features in follow-up requests.
  • Not specifying units. OpenSCAD is unitless; slicers usually assume millimeters.
  • Low $fn values leaving faceted holes that print undersize. Set a higher $fn for final exports, or use $fa and $fs.

Summary

Good OpenSCAD prompts ask for named, Customizer-ready parameters, modules, and an explicit assumptions list, and they keep review separate from rewriting. These five patterns cover new parts, refactors, tolerances, enclosures, and printability checks. More patterns are available on the products page.

Related