Your first shape

Your first shape

cube, cylinder, sphere — objects with dimensions in millimetres.

OpenSCAD doesn't describe solids with the mouse — you write a few short commands, press F5 (quick preview) or F6 (clean render), and see the result in the window next to your code. Dimensions are always in millimetres. That's everything you need to get started.

The three primitive solids

cube([30, 20, 15]);       // box: width, depth, height
cylinder(h = 20, d = 12); // cylinder: height, diameter
sphere(d = 24);           // sphere: diameter

cube([30, 20, 15]) makes a box 30 mm wide, 20 mm deep and 15 mm tall. Type one of these lines into OpenSCAD, press F5 — and there's your first shape.

cube([30, 20, 15]) — drag to rotate, scroll to zoom

Good to know

  • Every statement ends with a semicolon ;. Leave it out and OpenSCAD complains.
  • Anything after // is a comment and is ignored — handy for notes to yourself.
  • By default a solid sits with one corner at the origin. With center = true its centre goes to the origin, which is often easier when you combine shapes:
cube([30, 20, 15], center = true);

Exercise

Make a cube 25 mm on each edge.

Show solution
cube([25, 25, 25]);
// Shorter, when all edges are the same length —
// a single number is enough:
cube(25);
An unhandled error has occurred. Reload 🗙

Rejoining the server…

Rejoin failed… trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.