Parametric CAD workflow
A parametric model is a recipe, not a sculpture: change one number and the whole part follows. This page shows how to capture design intent, keep tolerances as named parameters, script a complete box with a snap-fit lid in OpenSCAD, iterate with cheap test prints and share the result so others can remix it.
How to think in parameters and constraints, build models sketch-first with a clean feature tree, name and version files, keep one table of tolerances per printer and material, write a parametric box with lid in OpenSCAD (full code below), run short test-print cycles, use Git for design history, publish with a license and print settings, and use AI assistance without trusting it blindly. The software itself is covered in CAD modeling; the numbers come from Tolerances & fits.
🔰 Parametric thinking
A direct (mesh or sculpt) model remembers only its final shape. A parametric model remembers how it was made: the sketches, the dimensions, the order of operations. Edit a dimension and the software replays the recipe. For 3D printing this is the single most useful habit, because you will almost always need to print a part more than once: the first print is a measurement, not a result. Every fit that is slightly off (0.2 mm is enough) becomes a one-line change instead of an hour of rework.
Parametric modeling is not only for engineers. A phone stand for your phone and your friend's bulkier model is a one-parameter change. A box for a new electronics board is a two-parameter change. The rule of thumb: if you can imagine printing it twice, make it parametric.
🔰 Design intent
Design intent is the reason behind each dimension. "The lid lip is 0.25 mm smaller than the box opening, always" is intent. "The lip is 59.5 mm long" is only a number. When intent is encoded as a relationship (lip = inner − 2 × clearance), the model survives changes. When intent is hidden in typed numbers, the model breaks as soon as one dimension is edited.
Capture intent in three places: (1) in the names of parameters (wall, clearance, not d12), (2) in formulas and constraints, and (3) in comments or a short note on the first line of the file (what the part is, the units, the printer and material it was tuned for).
🔰 Sketch-first workflow
In feature-based CAD (Fusion, FreeCAD, Onshape, SolidWorks) every solid starts from a 2D sketch. A clean sketch is the foundation: if the sketch is fully constrained, the features that depend on it behave predictably. Work in this order:
- Parameters first. Create named parameters for the interface (screw size, board size, wall, clearance). Never type a measurement twice.
- Base sketch. Draw the main profile on the plane that will lie on the bed. Constrain it fully: dimensions from parameters, symmetry about the origin, coincident or tangent where parts meet.
- Primary feature. Extrude or revolve once. Name it (Body_Extrude).
- Subtractive features. Cut pockets, holes and slots in a deliberate order: large cuts first, details last.
- Fillets and chamfers last. Round edges after the geometry is stable; they are the first things to break when the model is edited. Add the bottom-edge chamfer (0.4–0.6 mm) for elephant-foot control last of all.
- Check printability. Section the model, measure walls, check the overhangs (≤ 45°) and the orientation.
If a model breaks on every edit, the usual cause is a sketch attached to an edge or face that changed its index. Attach sketches to origin planes or to named datum planes instead of faces of earlier features.
🔧 Variables, spreadsheets and design tables
Every parametric program has a place for named values: Fusion's User Parameters, FreeCAD's Spreadsheet workbench, Onshape's Variables, SolidWorks' Equations and Design Tables, OpenSCAD's top-of-file variables. A design table is a spreadsheet where each row is a configuration (for instance S, M, L or PLA, PETG) and each column a parameter. Change the active row, get a different variant.
| Naming style | Example | Use for |
|---|---|---|
| Short, lowercase, units implied | wall, inner_x | Dimensions in mm |
| Prefixed groups | fit_slip, fit_press | Tolerance parameters |
| Derived (never typed) | outer_x = inner_x + 2 * wall | Anything calculable |
| Boolean switches | use_inserts = true | Optional features |
| Hardware tables | m3_clear = 3.4 | Screw and nut sizes |
🔧 Tolerance parameters per printer and material
Clearances are not constants of the universe: they belong to a printer + nozzle + material + settings combination. Store them in one block at the top of every model so the rest of the model never contains a bare clearance number. When you move to a new filament, you change the block, not the geometry. Start from the values in calibration offsets, then adjust them after a tolerance coupon print.
| Parameter | Meaning | Typical start (mm) |
|---|---|---|
| fit_press | Interference-ish fit, parts need force | 0.00–0.10 |
| fit_snug | Hand-press, no play | 0.10–0.20 |
| fit_slip | Slides by hand, minimal play | 0.20–0.30 |
| fit_loose | Free movement, visible play | 0.40–0.60 |
| fit_pip | Print-in-place gap per side | 0.30–0.50 |
| hole_add | Compensation for undersized circles | 0.15–0.40 |
| shrink_pct | Material shrinkage on long dimensions | 0.2–1.0 % |
Put the printer name and filament in the first comment line: // tuned: X2D, PETG, 0.4 nozzle, 0.2 layer. Six months later you will know which set of clearances you were using.
🔧 Modular libraries
Do not rebuild the same screw boss, hinge or snap hook every time. Keep a small library: one file per reusable feature, each with documented parameters and a test render. In OpenSCAD this is include or use; in Fusion it is a component library or a derived design; in FreeCAD it is a part you link with App::Link; in CadQuery or build123d it is a plain Python module. Good libraries are small, single-purpose and parameterized by interface (screw size, board size) rather than by raw dimensions.
🚀 Scripted CAD: OpenSCAD, CadQuery and build123d
Scripted CAD describes the part in code. Its strengths for printing are: every parameter is a variable by default, the file is plain text (so Git works perfectly), loops and conditions generate patterns (vents, gear teeth, grids) and the same file produces many variants. Its weaknesses: no direct manipulation, steeper learning curve and less comfortable filleting. A practical split: script the parametric, repetitive parts (enclosures, brackets, adapters) and use interactive CAD for organic or one-off shapes.
| Tool | Language | Kernel | Strengths | Watch out |
|---|---|---|---|---|
| OpenSCAD | Own declarative language | Mesh (CGAL / Manifold) | Simple, huge library base, Customizer panel | No true fillets; slow on complex booleans in older versions |
| CadQuery | Python | OpenCASCADE (B-rep) | STEP export, fillets, chamfers, selectors | Selector syntax takes time |
| build123d | Python | OpenCASCADE (B-rep) | Clear builder syntax, strong typing | Younger ecosystem |
Complete example: parametric box with snap-fit lid (OpenSCAD)
The code below is a complete, working model. It makes a box with rounded corners and a lid whose inner lip carries two snap bumps; the box has matching grooves. Paste it into OpenSCAD, press F5 to preview and F6 to render. Choose view in the Customizer: print lays both parts on the bed, assembled shows the closed box with a section. Every dimension is in millimeters.
// Parametric box with snap-fit lid
// Units: mm. Tuned: 0.4 nozzle, 0.2 layer, PETG. Print lid plate-down.
/* [View] */
view = "print"; // [print, assembled, box, lid]
/* [Box size] */
inner_x = 60; // inside length
inner_y = 40; // inside width
inner_z = 25; // inside height
wall = 1.6; // 4 lines of 0.4
floor_t = 1.2; // 6 layers of 0.2
corner_r = 3; // outside corner radius
/* [Lid and snap] */
lid_t = 1.6;
lip_h = 3; // how deep the lip goes
lip_t = 1.2; // lip wall thickness
clearance = 0.25; // per side (slip fit)
bump = 0.5; // snap bump height
bump_h = 1.2; // bump height along z
bump_w = 10; // bump width along the wall
/* [Hidden] */
$fn = 48;
eps = 0.01;
outer_x = inner_x + 2 * wall;
outer_y = inner_y + 2 * wall;
box_h = floor_t + inner_z;
groove_d = bump + clearance;
module rrect(x, y, h, r) {
linear_extrude(height = h)
offset(r = r) square([x - 2 * r, y - 2 * r], center = true);
}
// Snap bump profile: 45 degree lead-in, steeper return. Pointing +x.
module snap_bump() {
rotate([90, 0, 0])
linear_extrude(height = bump_w, center = true)
polygon([[-0.5, -bump_h/2], [0, -bump_h/2],
[bump, -bump_h/2 + bump], [bump, bump_h/2 - bump/2],
[0, bump_h/2], [-0.5, bump_h/2]]);
}
module box() {
difference() {
rrect(outer_x, outer_y, box_h, corner_r);
translate([0, 0, floor_t])
rrect(inner_x, inner_y, inner_z + eps, max(corner_r - wall, 0.2));
// grooves in the two short walls, matching the bumps
for (s = [-1, 1])
translate([s * inner_x / 2, 0, box_h - lip_h / 2])
cube([2 * groove_d, bump_w + 2 * clearance,
bump_h + 2 * clearance], center = true);
}
}
module lid() {
lip_x = inner_x - 2 * clearance;
lip_y = inner_y - 2 * clearance;
union() {
rrect(outer_x, outer_y, lid_t, corner_r);
translate([0, 0, lid_t - eps])
difference() {
rrect(lip_x, lip_y, lip_h + eps, max(corner_r - wall, 0.2));
translate([0, 0, -eps])
rrect(lip_x - 2 * lip_t, lip_y - 2 * lip_t,
lip_h + 3 * eps, 0.2);
}
// bumps on the outside of the lip, in the middle of its height
translate([ lip_x / 2, 0, lid_t + lip_h / 2]) snap_bump();
translate([-lip_x / 2, 0, lid_t + lip_h / 2]) mirror([1, 0, 0]) snap_bump();
}
}
if (view == "box") box();
else if (view == "lid") lid();
else if (view == "assembled") {
difference() {
union() {
box();
translate([0, 0, box_h + lid_t]) rotate([180, 0, 0]) lid();
}
translate([0, 0, -1]) cube([outer_x, outer_y, 2 * box_h + 4]); // quarter cut-away
}
}
else {
box();
translate([outer_x + 10, 0, 0]) lid();
}
Each outside size is derived (outer_x = inner_x + 2 × wall). The lid lip is smaller than the box opening by clearance on each side. The bump is a 45° ramp on the lead-in so the lid slides on, with a steeper return edge so it holds. The groove is cut bump + clearance deep so the bump has room to snap in. If the snap is too tight, reduce bump to 0.4; too loose, raise it to 0.6. A matching file may be provided in Models if available.
The same box in Python (CadQuery, build123d)
Python CAD gives true fillets and exports STEP files, which many CAD programs and CAM tools read. The shapes below are sketches that show the style; API names change between versions, so check the current documentation of your library before copying.
# CadQuery: body of the box (sketch of the approach)
import cadquery as cq
inner_x, inner_y, inner_z = 60, 40, 25
wall, floor_t, corner_r = 1.6, 1.2, 3
body = (cq.Workplane("XY")
.rect(inner_x + 2 * wall, inner_y + 2 * wall)
.extrude(floor_t + inner_z)
.edges("|Z").fillet(corner_r))
cavity = (cq.Workplane("XY").workplane(offset=floor_t)
.rect(inner_x, inner_y).extrude(inner_z + 1))
box = body.cut(cavity)
cq.exporters.export(box, "box.step")
# build123d: the same box with the builder syntax
from build123d import *
inner_x, inner_y, inner_z = 60, 40, 25
wall, floor_t, corner_r = 1.6, 1.2, 3
with BuildPart() as box:
Box(inner_x + 2 * wall, inner_y + 2 * wall, floor_t + inner_z,
align=(Align.CENTER, Align.CENTER, Align.MIN))
fillet(box.edges().filter_by(Axis.Z), radius=corner_r)
with Locations((0, 0, floor_t)):
Box(inner_x, inner_y, inner_z + 1,
align=(Align.CENTER, Align.CENTER, Align.MIN), mode=Mode.SUBTRACT)
export_step(box.part, "box.step")
🔧 Import, export and file formats
Keep the native parametric file as the source of truth and treat everything else as an export. Never edit an STL: it is a triangle soup with no intent.
| Format | Contains | Use it for | Notes |
|---|---|---|---|
| Native (f3d, FCStd, .scad, .py) | Parameters, history | Editing | Back up and version it |
| STEP | Exact B-rep shapes | Exchange between CAD programs, remixes | Best for editing in another CAD tool |
| 3MF | Mesh, units, colors, settings | Slicer hand-off | Preferred over STL; keeps scale and plates |
| STL | Triangle mesh only | Universal print file | Export at a tolerance of 0.01 mm; units are mm |
| OBJ | Mesh with colors | Multi-color and textures | Large files |
- Export in millimeters and check that the part is the right size in the slicer (a 100 × bigger or smaller part is the classic unit error).
- Use fine mesh resolution: chord tolerance ≤ 0.01 mm, angle ≤ 5° (curves look faceted otherwise).
- Check the mesh: closed (manifold), no flipped normals, no zero-thickness walls. See Files & meshes.
- Name exports with the version and the variant: sensor_box_v07_PETG_M.3mf.
- Position the part in the model with its bed face at z = 0 and the origin on a meaningful point, so the slicer's orientation is the intended one.
🔧 Naming and versioning
A consistent naming scheme saves hours. Use lowercase, underscores and numbers: project_part_vNN. Increase the version number when you print a new revision, not when you save. Write one line per version in a changelog (a text file next to the model): what changed, why, and the result of the print.
| Version | Change | Result |
|---|---|---|
| v01 | First fit test, clearance 0.2 | Too tight, lid does not close |
| v02 | clearance 0.3, bump 0.5 | Loose, lid rattles |
| v03 | clearance 0.25, bump 0.6 | Good snap; keep |
| v04 | Added vent slots | OK; check warping |
🚀 Design iteration cycles and test-print strategy
The fastest designers print small, often. A well-planned test print answers one question in minutes and costs a few grams of plastic. The cycle is: define the question → make the smallest model that answers it → print → measure → change one parameter → repeat.
Strategies for test sections:
- Print the interface only. Cut a 10–20 mm slice through the lip and wall; print with 2 walls and 0 % infill. This takes 5–10 minutes instead of two hours.
- Slice cut sections. In the slicer, set the model height limit (or cut the model with a plane tool) to print the bottom 5 mm, which includes the first layers, the elephant-foot chamfer and a hole pattern. Many slicers let you cut a model and keep one half.
- Parametric coupons. A strip with 0.1, 0.2, 0.3, 0.4 mm clearances engraved with the value, printed once per filament.
- Change one variable. If you change both the clearance and the orientation, you will not know which did what.
- Use cheap material for geometry, real material for fit. Test shape in any PLA; test strain and snaps in the final filament (PETG behaves very differently).
🔧 Version control with Git
Plain-text sources (OpenSCAD, Python, parameter files, markdown) fit Git perfectly: every change is a readable diff, you can go back to any version and you can branch to try a risky idea. Binary CAD files (Fusion archives, FCStd) are stored as whole files; Git keeps them, but cannot merge them, so commit often and name versions clearly. For large binaries use Git LFS or store them as releases.
# start a design repository
git init sensor-box
cd sensor-box
git add sensor_box.scad settings.scad CHANGELOG.md
git commit -m "v01: first box and lid"
# try an idea on a branch
git switch -c snap-lid
# ...edit, print a test slice, measure...
git commit -am "v02: bump 0.5, clearance 0.25"
# keep the winner
git switch main
git merge snap-lid
git tag v03-printed-petg
Add exported .3mf or .stl files to the repository only for released versions. Add a .gitignore for temporary exports and slicer cache folders.
🔧 Assembly modeling
When a product has several parts (box, lid, PCB, screws, magnets), model them in one assembly so you can check collisions and clearances before printing. Place each part with joints or mates instead of absolute positions: a lid mated to the top face of the box moves when the box grows. Use an interference check (the software can list overlaps) and an exploded view for the instructions. Include the purchased hardware as simple reference models (a cylinder for a screw, a prism for a nut) with correct dimensions.
🔧 Documenting designs
Future you is a stranger. Write the documentation while the design is fresh: three minutes now, hours saved later. Keep it next to the model in a README.md and include:
- What it is and a photo of the printed result.
- A parameter table: name, meaning, default, allowed range.
- Print settings: printer, nozzle, layer height, walls, infill, supports, orientation, material.
- Bill of materials: screws, inserts, magnets, with sizes and quantity.
- Assembly steps (numbered) and a list of known issues.
- Changelog with the version you printed and the result.
🔧 Publishing, licenses and remixing
If you share a model, a short, clear page helps others print it right. Show good photos (including one in daylight with a ruler), the print settings, the orientation picture and the tolerance values used. Consider providing the source files (STEP or the script) so people can remix them, not only the STL.
Remix and Customizer. A remix is a derived model. Respect the original license: credit the author, link the source, mention what you changed and use the same or a compatible license if required. OpenSCAD's Customizer turns the top-of-file variables into a form with sliders, drop-downs and checkboxes (the comments such as // [print, assembled, box, lid] and /* [Box size] */ in the example above create them). Platforms that run the Customizer let users generate a custom size without installing anything. To make a script Customizer-friendly: keep parameters at the top, give each a one-line comment, group them with section comments and hide derived values under /* [Hidden] */.
🚀 Design review loop
Before the final print, run a short review. It is a loop, not a one-off: each pass checks printability, function and documentation. Use the design review checklist from Principles and your parameter table.
| Question | Where to check |
|---|---|
| Do all fits come from named parameters? | Parameter block |
| Are walls ≥ 2 lines (0.8 mm) everywhere? | Section view, slicer preview |
| Overhangs ≤ 45° or supported by design? | Overhang analysis in the slicer |
| Is the main load along the layers? | Strength & orientation |
| Do mating parts collide or leave gaps? | Assembly interference check |
| Can the part be assembled in the planned order? | Exploded view |
⚠️ AI-assisted modeling: cautions
Language models and generative tools can write OpenSCAD or Python CAD code, suggest parameter names and explain an unfamiliar API. They are useful for first drafts and boilerplate, especially for repetitive shapes. They are not a replacement for checking, and they fail in specific ways:
- Plausible but wrong geometry. Code may run without errors and still make a lid that does not fit, a wall that is 0.1 mm, or an overhang at 90°. Always render and look at a section.
- Invented functions and outdated APIs. Libraries such as CadQuery and build123d change; a generated call may not exist in your version. Read the current documentation.
- No knowledge of your printer. The numbers (clearance, wall, bump) come from general text, not from your coupon. Replace them with your own parameter set.
- Units and scale. Models sometimes mix mm and inches or place the part away from the origin.
- Licensing. Generated code or shapes may resemble existing designs. Treat them as unreviewed and do not publish blindly.
- Safety. Do not use generated designs for loaded, hot, electrical or medical parts without independent calculation and testing.
Key takeaways
- Parametric means recipe: named parameters, formulas for relationships, features in a deliberate order (fillets last).
- Keep tolerances in one block per printer, nozzle and material; geometry never contains a bare clearance number.
- Script repetitive parts (OpenSCAD, CadQuery, build123d); the complete box-and-lid above is a starting library.
- Print small test slices (5–10 minutes) to settle a fit before the full part, and change one value at a time.
- Use Git or a changelog; export 3MF/STEP from a native source; document and license what you publish.
- Treat AI-generated models as unreviewed drafts: render, section, replace the numbers and test.
Next: practice with the Level 2 exercises and browse Design patterns for modules to build into your library. For the rules behind the numbers, see Principles, Tolerances & fits and Joints & fasteners.