Last active
October 9, 2024 03:50
-
-
Save creationix/e5a8f773c9910f4b3f6a6fedb9085754 to your computer and use it in GitHub Desktop.
Hexy Compute Shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include <Chamfer.scad>; | |
hex_radius=72.74597; | |
hex_height=33.50021; | |
// 2mm walls | |
wall_thickness=2; | |
gap=6; | |
difference() { | |
cylinder(h=hex_height,r=hex_radius, $fn=6); | |
translate([0,0,hex_height-gap]) | |
cylinder(h=hex_height,r=hex_radius-wall_thickness/sin(60), $fn=6); | |
all_etching(); | |
} | |
lid_thick_lower=3; | |
lid_thick_high=6; | |
lid_slope_width=12; | |
lid_radius=hex_radius-(gap+wall_thickness)/sin(60); | |
lid_radius_inner=lid_radius-lid_slope_width/sin(60); | |
translate([0,0,hex_height-(lid_thick_high-lid_thick_lower)]) | |
{ | |
cylinder( | |
h=lid_thick_lower, | |
r=lid_radius, | |
$fn=6 | |
); | |
difference() { | |
translate([0,0,lid_thick_lower]) | |
cylinder( | |
h=lid_thick_high-lid_thick_lower, | |
r1=lid_radius, | |
r2=lid_radius_inner, | |
$fn=6 | |
); | |
translate([0,0,lid_thick_high+.01]) | |
rotate([180,0,0]) | |
chamfer_extrude(height=1.01, angle=45, $fn=6) | |
rotate([0,0,30]) | |
import("lid-etching-big-thin.svg", center=true); | |
} | |
} | |
module etching() { | |
translate([hex_radius/2,-hex_radius*sin(60)-0.01,0]) | |
rotate([90,0,180]) { | |
chamfer_extrude(height=1.01, angle=45, $fn=6) | |
import("etching-thin.svg"); | |
} | |
} | |
module all_etching() { | |
for (i=[0:60:300]) { | |
rotate([0,0,i]) etching(); | |
} | |
} | |
module chamfer_extrude(height = 2, angle = 10, center = false) { | |
/* | |
chamfer_extrude - OpenSCAD operator module to approximate | |
chamfered/tapered extrusion of a 2D path | |
(C) 2019-02, Stewart Russell (scruss) - CC-BY-SA | |
NOTE: generates _lots_ of facets, as many as | |
6 * path_points + 4 * $fn - 4 | |
Consequently, use with care or lots of memory. | |
Example: | |
chamfer_extrude(height=5,angle=15,$fn=8)square(10); | |
generates a 3D object 5 units high with top surface a | |
10 x 10 square with sides flaring down and out at 15 | |
degrees with roughly rounded corners. | |
Usage: | |
chamfer_extrude ( | |
height = object height: should be positive | |
for reliable results , | |
angle = chamfer angle: degrees , | |
center = false|true: centres object on z-axis [ , | |
$fn = smoothness of chamfer: higher => smoother | |
] | |
) ... 2D path(s) to extrude ... ; | |
$fn in the argument list should be set between 6 .. 16: | |
< 6 can result in striking/unwanted results | |
> 12 is likely a waste of resources. | |
Lower values of $fn can result in steeper sides than expected. | |
Extrusion is not truly trapezoidal, but has a very thin | |
(0.001 unit) parallel section at the base. This is a | |
limitation of OpenSCAD operators available at the time. | |
*/ | |
// shift base of 3d object to origin or | |
// centre at half height if center == true | |
translate([ 0, | |
0, | |
(center == false) ? (height - 0.001) : | |
(height - 0.002) / 2 ]) { | |
minkowski() { | |
// convert 2D path to very thin 3D extrusion | |
linear_extrude(height = 0.001) { | |
children(); | |
} | |
// generate $fn-sided pyramid with apex at origin, | |
// rotated "point-up" along the y-axis | |
rotate(270) { | |
rotate_extrude() { | |
polygon([ | |
[ 0, 0.001 - height ], | |
[ height * tan(angle), 0.001 - height ], | |
[ 0, 0 ] | |
]); | |
} | |
} | |
} | |
} | |
} |
Author
creationix
commented
Oct 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment