-
-
Save VorpalBlade/ff941cb400cce6a8ddeebd465692979f to your computer and use it in GitHub Desktop.
Learning OpenSCAD
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
// This is an OpenSCAD re-creation of the following part I made earlier: | |
// https://www.printables.com/model/197700-tent-guylineparacord-tensioner | |
// Width of the object [mm] | |
width = 13; | |
// Length of the object [mm] | |
length = 36.5; | |
// Thickness of object [mm] | |
thickness = 3.6; | |
// Diameter of holes [mm] | |
hole_diam = 4.9; | |
// Size of chamfer [mm] | |
chamfer = 1; | |
module __Customizer_Limit__ () {} | |
// Calculate centers of holes | |
hole_locations = [ | |
[0, 0, 0], | |
[0, -length/2+width/2, 0], | |
[0, length/2-width/2, 0], | |
]; | |
$fa = 1; | |
$fs = 0.2; | |
// Make the basic shape | |
module Base2D() { | |
union() { | |
translate([0, -length/2+width/2, 0]) circle(d=width); | |
translate([0, length/2-width/2, 0]) circle(d=width); | |
square([width, length-width], true); | |
} | |
} | |
// Crude and complex helper to create the chamfered shape. | |
module ChamferedConvex(xydelta, zdelta, ztotal) { | |
hull() { | |
translate([0, 0, ztotal/2-zdelta]) | |
linear_extrude(height=zdelta) | |
offset(delta=xydelta, chamfer=true) | |
children(); | |
translate([0, 0, -thickness/2]) | |
linear_extrude(height=zdelta) | |
offset(delta=xydelta, chamfer=true) | |
children(); | |
linear_extrude(height=ztotal - 2 * zdelta, center=true) | |
children(); | |
} | |
} | |
module Base3D() { | |
ChamferedConvex(xydelta=-chamfer, zdelta=chamfer, ztotal=thickness) | |
Base2D(); | |
} | |
// Unfortunately we can't use the generic chamfer helper to deal with the holes, | |
// as the overall shape is not convex... | |
module HourGlass(min_diam, max_diam, total_height, middle_section_height) { | |
// This is stupidly complicated. There must be a better way to make a hole | |
// with chamfered ends... | |
end_height = (total_height-middle_section_height)/2; | |
zoffset = end_height/2+middle_section_height/2; | |
cylinder(h=total_height+0.01, r=min_diam/2, center=true); | |
translate([0, 0, -zoffset]) | |
cylinder(h=end_height+0.01, r1=max_diam/2, r2=min_diam/2, center=true); | |
translate([0, 0, zoffset]) | |
cylinder(h=end_height+0.01, r2=max_diam/2, r1=min_diam/2, center=true); | |
} | |
module Holes3D() { | |
for (i = [0:len(hole_locations)-1]) { | |
translate(hole_locations[i]) | |
HourGlass(min_diam=hole_diam, | |
max_diam=hole_diam+2*chamfer, | |
total_height=thickness, | |
middle_section_height=thickness-2*chamfer); | |
} | |
} | |
module main() { | |
difference() { | |
Base3D(); | |
Holes3D(); | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment