Lab 5: Prototyping in OpenScad and 3D Printing
In this lab you will:
- build your 3D printer and learn how to use it,
- learn how to design custom 3D parts using OpenScad,
- make an instrument using 3D printing.
Setting Up Your 3D Printer
Warning: this first part of the lab will take you approximately 6h to complete if all goes well: make sure to plan ahead!
Getting OpenScad
OpenScad is an open source Computer Assisted Design (CAD) software that is used through a text-based programming language. It is a very powerful tool to design ready-to-be-printed 3D parts. It can compete in many respects with graphical-based commercial tools like SolidWorks, Rhino, etc. for this kind of applications (e.g., OpenScad doesn’t really provide any “assembly tool”).
Download and install OpenScad.
Make Your First Design in OpenScad
- Create a new file (
.scad
extension) in OpenScad.
- The left window allows you to write “the code of your design” (editor) and the right window to visualize it.
- In the editor, create a cube of dimensions 20x20x20:
cube([20,20,20]);
- The unit of shapes in OpenScad is arbitrary but Cura will assume that we’re using millimeters. So the dimensions of our cube here are in millimeters.
- The most useful resource when using OpenScad is its Cheat Sheet. Have a quick look at it and try to spot the
cube
function in it!
- The preview button allows you to quickly visualize the shape corresponding to your code. Try to preview your cube!
- The render button produces the final file of your design but takes more time. You’ll have to render your design every time you’ll want to 3D print it.
- One the most common task when designing something is to put holes in it (e.g., for screws, etc.), so let’s try to add a hole at the middle of our cube. This can be done by differentiating a cylinder from the cube:
difference(){
cube([20,20,20]);
translate([10,10,0])cylinder(h=20,d=10);
}
h=20
sets the height of the cylinder (same as the cube) and d=10
sets the diameter of the cylinder. translate
is used to move the cylinder at the center of the cube. difference
carries out the differentiation.
- Try to render your design. You’ll probably notice that the 3D graphical representation doesn’t look exactly how expected. This is due to some errors in the preview process. Rendering the object should fix them.
- You’re probably also wondering why the hole has such a low resolution. That’s a parameter you can configure using the
$fn
globale variable. Hence, in:
$fn = 50;
difference(){
cube([20,20,20]);
translate([10,10,0])cylinder(h=20,d=10);
}
the hole at the middle of the cube will be made out of 50 faces. Adding more faces will increase the rendering time so you’ll always have to find the right balance for this parameter. For example, you could give it a value when prototyping and you could increase it when you’re ready to print your part.
- At this point, you’re ready to make your first print from OpenScad. Render the shape and then export it to STL. Then, open Cura and drag and drop the STL file in it. Finally, print your part (the default parameters should work fine for this design)!
Some Tips on Making the Best of OpenScad
- Believe it or not, but at this point you know almost everything about OpenScad! It always works the same way: you start from a simple existing shape (e.g., a cube, a cylinder, etc.) that you then modify to create more complex shapes.
- At this point, we advise you to have another look at the OpenScad cheat sheet.
- Since OpenScad is a programming language, it’s easy to iterate on something using loops, etc. For example, it’s super simple to copy the previous design three times:
$fn = 50;
for(i = [0:2]){
translate([30*i,0,0])difference(){
cube([20,20,20]);
translate([10,10,0])cylinder(h=20,d=10);
}
};
- More complex shapes can be created using polygons. For example:
linear_extrude(height=10)polygon(points=[[0,0],[10,0],[10,10]]);
creates a 2D right triangle of size 10x10 which is then turned into a 3D triangle of height 10 through a linear extrusion.
Exercise 1: Making a “Tray” Module
- Modules allow us to create functions in OpenScad. Functions are useful to create objects that can be reused.
- Create a tray module in OpenScad to generate an object with the following shape:
(a cube with a cubic cavity in it).
- Your module should have the following format:
tray(x=150,y=100,z=40,walls=10)
where x
, y
, and z
are the dimensions of the tray and walls
the thickness of its walls.
Potential solution
Exercise 2: Making a Pyramid
- Make a 100x100x100 pyramid in OpenScad.
Potential solution
Laser Cutting
Laser cutting will potentially be an option for your final project. To get an idea of how the laser cutter in the CCRMA garage works, please check lab 4 from 2018 and the CCRMA Laser Cutter Documentation Page.
Assignment A (Due on Feb. 16, 2022)
- This is not an assignment per se but we want you to do all the lab on this page. The reason why we consider it as an assignment is because we know it will be time consuming.
- There’s no deliverable for this “assignment”
Assignment B (Due on Feb. 23, 2022)
- Make an instrument involving some 3D printing. The 3D printed part of your instrument could be its case, its body, etc. It could also be an element that augments/interacts with an existing object like John Granzow’s Javalele.
- Your instrument should use sensors as well as your Teensy.
- Try to use your 3D printer wisely: don’t make a huge 2D plate with holes while you could simply take a wood plate and drill holes through it. Use your printer for something that you couldn’t do without it.
- If you feel more comfortable using another CAD software than OpenScad (e.g., SolidWorks, Rhino, etc.), feel free to do so.
- Make sure that your instrument is expressive, artful, beautiful, playable, etc.
- Make a video of yourself playing it and post it on YouTube.
- Send the link of this video along with the source code of your instrument to Mike and Romain by Feb. 23, 2022.
- Good luck and have fun!