Python in 3D

Write a few lines of Python and watch a real shape appear: a circle here, a rectangle there, maybe some text. Once that feels natural, this adds one more axis. Instead of drawing on a flat page, you’re placing shapes in space. Instead of pixels, what you build is a real 3D model you can spin around, print, and hold.

New to this whole idea? Read where it comes from before diving in.

The idea in short

  • Box(...) and Cylinder(...) are 3D shapes you already understand from their 2D cousins. They just also have a height now.
  • Rect, Circle, RegularPolygon, Polygon, and Label are flat 2D shapes, exactly like the ones you’ve drawn before. They show up flat at first; extrude(...) gives one real height, and rotate_extrude(...) spins one around an axis instead, like a shape on a potter’s wheel.
  • union(), difference(), and intersection() combine shapes: glue them together, cut one out of another, or keep only where they overlap.
  • hole=True is a shortcut for the single most common thing you’ll want to do, which is drilling a hole through something.
  • When you’re happy with it, Download STL gives you a file ready for a 3D printer.

None of this needs to be memorized going in. The cheatsheet has the full syntax for everything, and the Studio’s starter code is already a working example to poke at.

This lives on learn.porttack.com, a small site of CS and robotics teaching material. This page is just one part of it, so feel free to look around.