Part 5 · Design for printing

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.

Intermediate⏱ 55 min read
What you will learn

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.

Parameters inner_x = 60inner_y = 40wall = 1.6clearance = 0.25screw_d = 3material = "PETG" Modelsketches · featuresformulas · patterns SML One recipe3 sizes3 materials2 printers= 18 parts,one file
Figure 1. Parameters in, parts out. The model is the same; only the numbers change.

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.

Bad: typed numbers box 60 → 70 and the lid still says 59.5lid no longer fits Good: relationships lip = inner − 2 × clearancechange inner_x and the lid follows
Figure 2. Encode the relationship, not the result. Anything that must match another feature should be calculated from it.

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:

  1. Parameters first. Create named parameters for the interface (screw size, board size, wall, clearance). Never type a measurement twice.
  2. 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.
  3. Primary feature. Extrude or revolve once. Name it (Body_Extrude).
  4. Subtractive features. Cut pockets, holes and slots in a deliberate order: large cuts first, details last.
  5. 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.
  6. Check printability. Section the model, measure walls, check the overhangs (≤ 45°) and the orientation.
Under-constrainedsome lines drift when you dragfix: add dimensions and symmetry inner_x Fully constrainedblack: every line is definednothing moves unless a parameter does Over-constrainedtwo dimensions fight each otherfix: delete the redundant one
Figure 3. Sketch states. Aim for fully constrained sketches (the color code differs by program), never over-constrained ones.
Tip

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.

Clean feature tree ▸ Parameters▸ Sketch_Base (constrained)▸ Body_Extrude▸ Cut_Cavity▸ Boss_Pattern (×4)▸ Cut_Screw_Holes▸ Fillet_Outside▸ Chamfer_Bottom Fragile feature tree ▸ Sketch1▸ Extrude1▸ Fillet1 (all edges)▸ Sketch2 on a face of Fillet1▸ Cut2▸ Extrude3 (?)▸ Fillet4▸ Sketch5 (copy of Sketch2)
Figure 4. The order of features is the architecture of the model. Name every feature; put fillets last.

🔧 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.

variantinner_xinner_ywallscrew S40301.6M2.5 M60401.6M3 L100702.4M4 TPU60402.0M3 active row: Mmodel rebuilds
Figure 5. A design table drives variants. Switch the active row and the model rebuilds.
Naming styleExampleUse for
Short, lowercase, units impliedwall, inner_xDimensions in mm
Prefixed groupsfit_slip, fit_pressTolerance parameters
Derived (never typed)outer_x = inner_x + 2 * wallAnything calculable
Boolean switchesuse_inserts = trueOptional features
Hardware tablesm3_clear = 3.4Screw 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.

X2D · PLA · 0.4 fit_press = 0.05fit_snug = 0.12fit_slip = 0.22fit_loose = 0.40fit_pip = 0.30hole_add = 0.15verified: coupon v3 X2D · PETG · 0.4 fit_press = 0.08fit_snug = 0.15fit_slip = 0.28fit_loose = 0.45fit_pip = 0.35hole_add = 0.20PETG swells at the layer edge X2D · ASA · 0.4 fit_press = 0.05fit_snug = 0.12fit_slip = 0.25fit_loose = 0.42fit_pip = 0.32hole_add = 0.18add shrink 0.5 % to long parts
Figure 6. Example parameter sets (diametral clearances, mm). They are starting points: your coupon decides the real values.
ParameterMeaningTypical start (mm)
fit_pressInterference-ish fit, parts need force0.00–0.10
fit_snugHand-press, no play0.10–0.20
fit_slipSlides by hand, minimal play0.20–0.30
fit_looseFree movement, visible play0.40–0.60
fit_pipPrint-in-place gap per side0.30–0.50
hole_addCompensation for undersized circles0.15–0.40
shrink_pctMaterial shrinkage on long dimensions0.2–1.0 %
Trick

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.

settings.scadfits · printer · units bosses.scad snaps.scad hinges.scad sensor_box.scad tool_holder.scad
Figure 7. A settings file feeds feature libraries, and projects import the libraries. Change the settings once; everything follows.

🚀 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.

ToolLanguageKernelStrengthsWatch out
OpenSCADOwn declarative languageMesh (CGAL / Manifold)Simple, huge library base, Customizer panelNo true fillets; slow on complex booleans in older versions
CadQueryPythonOpenCASCADE (B-rep)STEP export, fillets, chamfers, selectorsSelector syntax takes time
build123dPythonOpenCASCADE (B-rep)Clear builder syntax, strong typingYounger 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.

inner_x inner_z + floor lip_h 3 wall 1.6 lid_t 1.6 clearance 0.25 bump 0.5, groove +0.25 Section: box + lid (closed)
Figure 8. The parameters of the box-and-lid model. Lip outer size = inner size − 2 × clearance; groove depth = bump + clearance.
// 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();
}
How it works

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.

FormatContainsUse it forNotes
Native (f3d, FCStd, .scad, .py)Parameters, historyEditingBack up and version it
STEPExact B-rep shapesExchange between CAD programs, remixesBest for editing in another CAD tool
3MFMesh, units, colors, settingsSlicer hand-offPreferred over STL; keeps scale and plates
STLTriangle mesh onlyUniversal print fileExport at a tolerance of 0.01 mm; units are mm
OBJMesh with colorsMulti-color and texturesLarge files

🔧 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.

VersionChangeResult
v01First fit test, clearance 0.2Too tight, lid does not close
v02clearance 0.3, bump 0.5Loose, lid rattles
v03clearance 0.25, bump 0.6Good snap; keep
v04Added vent slotsOK; 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.

Question Small model Print 10 min Measure Change 1 value repeat until the fit is right (usually 2–4 loops) when the fit works: print the full part
Figure 9. A fast inner loop on small test pieces, then one confident final print.

Strategies for test sections:

Full part: 2 h 10 min Test slice: 8 min Slice contains • the lip or thread to check• 2 walls, no infill• one corner and one wall• the mating test piece Saves 95 % of time and plastic.Check against the real mating part.
Figure 10. Print just the corner that contains the fit: the result tells you about the whole part.

🔧 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.

v01v02 basemergev03 tag try snap lidtune bumpvents mainbranch: snap-lid
Figure 11. A branch explores a new lid; the merge brings it into main only when it prints well. Tag the versions you actually printed.
# 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
Tip

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.

3 · lid (lip down) 4 · M3 screws × 4 2 · PCB on standoffs 1 · box with bosses mates:• lid ↔ box top (coincident)• PCB ↔ standoffs (slot)• screw ↔ boss (axis)
Figure 12. An exploded assembly numbered in the order of fitting. Mates keep parts related when parameters change.

🔧 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:

🔧 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.

hero photo + ruler print settings table orientation image parameters files + source license + remix Common licenses CC BY: share, remix, credit meCC BY-SA: remixes share alikeCC BY-NC: no commercial useCC0: public domainMIT / GPL: for code and scripts Check the license of every model youremix, and of every font and library.
Figure 13. A good model page and the licenses you will meet. Choose a license on purpose; "no license" usually means "all rights reserved".

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.

1 Requirements 2 Model 3 Printability 4 Test print 5 Second pair of eyes 6 Release Failed a check?go back to 2
Figure 14. The review loop: requirements, model, printability, test, second review, release. A failed check sends you back to the model, not forward.
QuestionWhere 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:

Draft code Read it Render + section Your parameters Test slice A draft is a starting point. Nothing reaches the final print without a render, a section and a test slice.
Figure 15. A safe flow for generated code: every draft goes through reading, rendering, your own numbers and a test print.

Key takeaways

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.