1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 06:08:31 +01:00
dotSCAD/examples/drilled_cube.scad
2020-10-01 11:54:14 +08:00

53 lines
1.4 KiB
OpenSCAD

width = 70;
joint_h = 2;
level = 4;
reducing_scale = 0.575; // [0:0.707107]
$fn = 8;
echo(atan2(1, sqrt(2)));
module drilled_cube(width, reducing_scale, joint_h, level) {
module drills(width, reducing_scale, joint_h, level) {
w = width * reducing_scale;
r = 1.41421 * w / 2;
if(level > 0) {
z_offset = w / 2 + joint_h;
for(i = [0:3]) {
rotate([i * 90, 0, 0])
translate([0, 0, z_offset])
linear_extrude(width)
circle(r);
}
for(ay = [90, -90]) {
rotate([0, ay, 0])
translate([0, 0, z_offset])
linear_extrude(width)
circle(r);
}
drills(z_offset * 2, reducing_scale, joint_h, level - 1);
}
else {
for(i = [0:3]) {
rotate([i * 90, 0, 0])
linear_extrude(width)
circle(r);
}
for(ay = [90, -90]) {
rotate([0, ay, 0])
linear_extrude(width)
circle(r);
}
}
}
difference() {
cube(width, center = true);
drills(width, reducing_scale, joint_h, level - 1);
}
}
drilled_cube(width, reducing_scale, joint_h, level);