--- name: cad-3d-print description: > Design, generate, and verify parametric 3D models for 3D printing using code-first CAD (OpenSCAD, build123d). scope: global --- # CAD 3D Print Design, generate, and empirically verify 3D-printable parts using programmatic CAD. Follow the [shared workflow](../../protocols/workflow.md). ## Workflow 1. **Dimensional Budgeting & Tolerances** - Establish bounding box, mounting points, and mating interfaces from user specifications. - Apply standard FDM 3D printing tolerances: - **Horizontal hole clearance:** Add `+0.2 mm` to `+0.3 mm` for screw pass-through (e.g. M3 hole diameter = `3.2 mm`; tap hole = `2.9 mm`). - **Fit clearances:** Snug/snap fit `0.15 mm`; sliding fit `0.3 mm`; loose/hinged fit `0.4–0.5 mm`. - **Wall thickness:** Multiples of nozzle width (minimum `1.2 mm` for 0.4 mm nozzles). - **Bed contact:** Add 45° chamfers to bottom edges touching the build plate to prevent "elephant's foot" binding. - **Overhangs:** Keep unassisted overhangs $\le 45^\circ$ to minimize support material. 2. **Parametric Script Generation** - Author a standalone, self-documenting OpenSCAD (`.scad`) script: - Place all customizable dimensions at the top as labeled parametric variables. - Set curvature resolution: `$fn = 60;` or `$fs = 0.5; $fa = 5;` for smooth circular features. - Use Constructive Solid Geometry (CSG): `union()`, `difference()`, `intersection()`, `hull()`. - Prevent non-manifold coincident faces (Z-fighting): always extend cutting bodies slightly beyond the target surface (e.g., `translate([0, 0, -0.1]) cylinder(h = height + 0.2, ...)`). 3. **Empirical Verification** - **Compile STL mesh:** ```bash openscad -o model.stl model.scad ``` Inspect compiler output to ensure `Simple: yes` (a manifold, watertight solid). - **Render visual preview:** ```bash openscad --render --imgsize=800,600 -o preview.png model.scad ``` - Verify the rendered image to check geometry, clearances, and aesthetic proportions. 4. **Handoff Artifacts** - Keep the editable `.scad` source in the workspace. - Provide the compiled `.stl` or `.3mf` for slicing (PrusaSlicer, Bambu Studio, OrcaSlicer). - Embed or link the rendered `.png` preview.