Parametric Design
β¨ PAN'S RULE: If it's not chaotic, it's not magic! β¨
Write code to generate 3D models using OpenSCAD. Change one variable and the whole design adapts.
Imagine building a LEGO house. To make it taller, you have to take the roof off and add more bricks one by one. Tedious! π§±
Normal Way
Parametric Way
What if you had a magic spell to just say "House, grow taller!" and it did? That's what parametric design is! You create rules (we call them "parameters"), and the computer rebuilds the object for you instantly. Let's learn the spells! π§
Coding 3D Models with OpenSCAD
OpenSCAD is a free tool that lets you design 3D models with code. If you want to change the size of a custom box, you don't use a drag-and-drop toolβyou just change a variable like width = 50; and re-run the code! Think of cube() as your magic LEGO brick. Instead of snapping blocks together, you're telling the computer the size of the brick you want.
π΅οΈ Knowledge Check
Look at this code: cube([30, 15, 10]); This makes a rectangular block. Which number would you change to make the block WIDER (the first value)?
The Magic Carver: Adding & Subtracting Shapes
CSG is a fancy term for adding and subtracting shapes. In the code below, we're using the difference() function to magically subtract a cylinder from the center of a cube. Hit the button to see what happens!
β Your Next Mission:
Awesome! You carved a hole. But it's too small for our secret spy bolt. Modify the code to make the hole bigger. Change the hole_radius variable from 5 to 8 and hit 'Compile Geometry' again!
π§ Behind the Magic: The Three Spells of CSG
You just used `difference()`, which is one of three 'magic spells' in Constructive Solid Geometry (CSG). It sounds complicated, but it's just like playing with digital clay! These are the words real engineers use:
- Union(): Glues two shapes together into one.
- Difference(): Carves one shape out of another (your carving spell!).
- Intersection(): Keeps ONLY the parts where two shapes overlap.
Make Something That's Uniquely YOURS!
Let's make something you can show off: a custom name tag for your backpack. This is way cooler than a boring cable holder and the perfect first project!
First, we need a solid block of digital material. This code makes a flat rectangle. The numbers are [width, depth, height]. Try changing them to see how the shape changes!
Now for the fun part! We'll use our difference() spell again, but this time with the text() command. The code below carves the word "Pan" into the tag. Change "Pan" to YOUR name and hit 'Carve It!' to make it your own!
π€ The Clone Machine!
Making one thing is cool. Making 100 is power. A for loop is a classic coding tool that repeats an action. It's like having a robot army to build for you!
This code makes one lonely fence post. Can you wrap it in a for loop to create a line of 5 posts? Hint: for (i = [0:4]) { ... } and use translate([i * 10, 0, 0]) inside!
β Intermediate Warm-Up: Build a Tower
You made a line of posts. Awesome! Now, can you make them stack up? Use a `for` loop and `translate` to stack 5 cubes on top of each other to build a tower. You'll need to change the `translate` to move on the Z-axis (the last number)!
π Level Up: Build Your Own LEGO Block with `module`
Real programmers hate copy-pasting code. It's messy! Instead, they package useful code into reusable blocks called modules. It's like creating your very own custom LEGO brick that you can use over and over.
You can turn your Name Tag code into a module that lets you create a tag of any size with any name, just by calling one command! This is a super powerful concept that bridges the gap to real engineering.
// 1. Define your own special command (module)
module name_tag(tag_width, tag_depth, your_name) {
difference() {
cube([tag_width, tag_depth, 5]);
translate([5, 8, 1])
text(your_name, size=20, font="Liberation Sans");
}
}
// 2. Now you can use it as many times as you want!
name_tag(80, 40, "Pan");
translate([0, 50, 0]) name_tag(100, 30, "Agent");
The AI Sandbox
Ready for a classic challenge? Try to build a spiral staircase. You'll need a `for` loop that uses `translate()` to move up AND `rotate()` to twist at each step. Here's a hint: `rotate([0, 0, i * 36])`. Go for it! π
π₯ Boss Level Challenge: Design a Planetary Gear
Feeling brave? A planetary gear system has a central "sun" gear and several "planet" gears that revolve around it. Can you use a for loop with rotate() and translate() to position several gears around a central point? This is a true engineering puzzle!
β¨ The Next Frontier: AI Dream-to-Object
Coding shapes is powerful, but what if you could just... ask for a shape? That's the next adventure! Tools like Spline AI let you type a sentence like "a friendly robot dragon holding a pizza" and an AI will generate a 3D model for you! The coolest part? You can often export these AI-generated models and import them into OpenSCAD to add your own parametric features, like custom holes or connectors. It's the perfect blend of AI creativity and your engineering control.
π‘οΈ AI Safety Check
- Be an Artist, Not a Client: Use AI as a starting point. It's a tool to help your creativity, not replace it!
- No Personal Info: Never type your full name, address, or school into an AI generator. Keep your private information private.
- Talk About It: If an AI makes something that seems weird or makes you uncomfortable, tell a parent or trusted adult right away.
π¨βπ©βπ§ For Parents: AI tools like this are amazing for creativity but often require an account. This is a perfect "explore together" activity. You can co-pilot the sign-up and be amazed at what your child dreams up!
π¨βπ©βπ§ Parent Corner: From Code to Creation
Curious how this code becomes a real object? OpenSCAD is free software you can install on any computer. When your child is happy with their design, the software exports an 'STL' file. This file is then put into another free program called a 'slicer' (like Ultimaker Cura or Bambu Studio) that prepares it for a 3D printer. This is a great project to explore together!
π Learn More
- OpenSCAD's Official Cheat Sheet - The perfect reference guide!
- Explore Customizable Models on Thingiverse - See what others are building with parametric design. (Always ask a parent before sharing your creations online!)
- Create Your Own Tools with OpenSCAD Modules - Learn how engineers package their code into reusable blocks.