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.
Lesson 1: Flat Shapes →
Draw rectangles and circles on a flat page: your first coordinates and your first shapes.
Lesson 2: Position and Size →
Give shapes real height: position, size, and your first boxes.
Lesson 3: Transformations →
Cylinders, rotate(), translate(), and how they compose.
Lesson 4: Combining Shapes →
union(), consuming shapes, and growing a compound shape with add()/+=.
Lesson 5: Cutting Shapes →
difference(), hole=, and cutting one shape out of another.
Advanced: Shapes of Revolution →
Optional bonus lesson. rotate_extrude() -- spin a profile around an axis instead of pushing it straight up.
Advanced: Polyhedrons →
Optional bonus lesson. Points and faces -- the raw building blocks every 3D shape (and every .stl file) is made of.
Open the Studio →
Write Python on the left, watch the model update live on the right.
Cheatsheet →
Every shape, transform, and option on one page.
The idea in short
Box(...)andCylinder(...)are 3D shapes you already understand from their 2D cousins. They just also have a height now.Rect,Circle,RegularPolygon,Polygon, andLabelare flat 2D shapes, exactly like the ones you’ve drawn before. They show up flat at first;extrude(...)gives one real height, androtate_extrude(...)spins one around an axis instead, like a shape on a potter’s wheel.union(),difference(), andintersection()combine shapes: glue them together, cut one out of another, or keep only where they overlap.hole=Trueis 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.