Skip to content

Instantly share code, notes, and snippets.

@tsnoad
Created February 28, 2016 06:01
Show Gist options
  • Save tsnoad/392ec1d6bde922dbca57 to your computer and use it in GitHub Desktop.
Save tsnoad/392ec1d6bde922dbca57 to your computer and use it in GitHub Desktop.
Simple openscad function/module to create ISO screw threads
module m5_thread(height=1,quality=4) {
r_maj = 5/2;
pitch = 0.8;
iso_h = sqrt(3)/2*pitch;
r_min = r_maj - 5/8 * iso_h;
linear_extrude(height=height,twist=360*height/pitch) hull() for(j=[0,1]) mirror([j,0,0]) for(i=[0:(180/8)/quality:180]) {
if (i==0) {
square([0.01,r_maj]);
} else if (i==180) {
translate([0,-r_min]) square([0.01,r_min]);
} else if (i<22.5) {
translate([min(0,r_maj*sin(i)),min(0,r_maj*cos(i))]) square([max(abs(r_maj*sin(i)),0.01),abs(r_maj*cos(i))]);
} else if (i>135) {
translate([min(0,r_min*sin(i)),min(0,r_min*cos(i))]) square([max(abs(r_min*sin(i)),0.01),abs(r_min*cos(i))]);
} else {
translate([min(0,(r_min+(1-(i-22.5)/112.5)*(r_maj-r_min))*sin(i)),min(0,(r_min+(1-(i-22.5)/112.5)*(r_maj-r_min))*cos(i))]) square([abs((r_min+(1-(i-22.5)/112.5)*(r_maj-r_min))*sin(i)),abs((r_min+(1-(i-22.5)/112.5)*(r_maj-r_min))*cos(i))]);
}
}
}
m5_thread(height=12);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment