-
Notifications
You must be signed in to change notification settings - Fork 0
/
tutorial.scad
100 lines (75 loc) · 2.04 KB
/
tutorial.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// INTRO TO OpenSCAD
// Code comments start with //
// Multiline comments are wrapped with /* and */
/*
VARIABLES
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General
Variables are used to store values for later use
*/
box_width = 30; // 30 milimeters (mm)
box_height = 20; // 20 mm
// Create a variable box_depth and set it equal to 40
/*
SOLID SHAPES
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids
*/
// CUBE [ width, depth, height]
//cube([box_width, box_depth, box_height]);
// SPHERE where r is the radius in mm
//sphere(r = 20);
// CYLINDER where h is the height and r is the radius in mm
//cylinder( h = 30, r = 20);
// Increase the resolution of curved edges by assigning $fn to a value.
$fn = 12; // try using changing this to 10, 24, 48 or 64
/*
TRANSLATION
Move objects in 3D space.
*/
// Move [ x, y , z ]
translate([20, -20, 0]) {
// Everything inside the { } will be translated
//cylinder( h=30, r=20);
}
// Try translating all of the shapes from above so that none of them overlap
// NOTE: Comment out the shapes above before moving on
/*
DIFFERENCE
Remove part of a solid shape.
*/
difference() {
// Shape
//cube([38, 60, 13]);
// Shape to remove from the above shape
translate([1.6, 1.6, 2]){
// Use # in front of a shape to make it semi-transparent
//#cube([34.8,76.8,24]);
}
// Micro usb slot
//#translate([14.79,-1,7.1])cube([8.2,4,4]);
}
/*
MODULES
Modules allow us to reuse shapes we've created.
*/
module pcbMount() {
cylinder( h = 6, r = 3);
cylinder( h = 10, r = 2);
cylinder( h = 12, r = 1.1);
}
// We can render a module by calling it.
//pcbMount();
module fourPcbMounts(pcb_width, pcb_depth) {
translate([10,4.65,0]) {
pcbMount();
}
translate([10 + pcb_width,4.65,0]) {
pcbMount();
}
translate([10 + pcb_width,4.65 + pcb_depth,0]) {
pcbMount();
}
translate([10,4.65 + pcb_depth,0]) {
pcbMount();
}
}
//fourPcbMounts(17.78, 45.72);