3D Printing & CNCTechnician

Design Parametric Parts with Code in OpenSCAD

Write a few lines of code to create mounts you can resize by changing one number — then remix our Vault files.

LevelTechnician
Time1.5 h
Est. cost~$270
Steps5

OpenSCAD is free CAD for programmers: you describe a part with shapes and math. Every model in our Vault includes its .scad source, so you can open it and change the dimensions.

Video tutorial

Video by Tom Nardi, embedded from YouTube. The written steps below are our own and match the parts list.

Mission steps

  1. Install OpenSCAD

    Download it free for Windows, macOS or Linux from openscad.org.

  2. Learn three shapes

    cube(), cylinder() and sphere() plus translate() to move them.

  3. Combine them

    union() joins shapes, difference() subtracts holes, hull() wraps shapes for rounded parts.

  4. Use variables

    Put sizes at the top (board width, hole spacing) so one change updates the whole model.

  5. Remix the Vault

    Open any Vault .scad file, edit a number, press F6 to render and F7 to export a new STL.

Code

// Parametric sensor plate
w = 40;  h = 25;  t = 3;      // plate size
hole = 3.4;  inset = 4;        // M3 clearance holes

difference() {
  hull() for (x = [3, w-3], y = [3, h-3]) translate([x, y, 0]) cylinder(r=3, h=t, $fn=40);
  for (x = [inset, w-inset], y = [inset, h-inset])
    translate([x, y, -1]) cylinder(d=hole, h=t+2, $fn=30);
}

Tip: test every script on the bench before installing it in a moving machine.

Questions

OpenSCAD or Fusion?

OpenSCAD is perfect for precise mechanical parts and easy to share as text. Visual CAD tools are better for organic shapes.