From 244fc8f0fd3809dc88f93365d82f23aea05925db Mon Sep 17 00:00:00 2001 From: Clinton Ebadi Date: Fri, 10 Nov 2017 14:24:00 -0500 Subject: [PATCH 1/1] acorn: v1.1 Move everything into a module to make it easier to generate different sizes. --- acorn/acorn-threads.scad | 225 +++++++++++++++++++-------------------- 1 file changed, 112 insertions(+), 113 deletions(-) rewrite acorn/acorn-threads.scad (86%) diff --git a/acorn/acorn-threads.scad b/acorn/acorn-threads.scad dissimilarity index 86% index b477ccb..1abc99e 100644 --- a/acorn/acorn-threads.scad +++ b/acorn/acorn-threads.scad @@ -1,113 +1,112 @@ -// Threads for acorn model -// Copyright (c) 2017 Clinton Ebadi - -use // http://www.thingiverse.com/thing:1686322 - -thread_pitch = 3.0; -thread_size = 2.5; //2.2; // 3.0 -thread_tooth_height = thread_pitch - 0.4; -thread_height = 3.5; //4.0; -wall_thickness = thread_size; -base_height = 25; -inner_d = 24.5; -outer_d = inner_d + wall_thickness*2; //33; - -internal_thread_tolerance = 0.3; -external_thread_tolerance = 0.2; -thread_angle = 50; - - -module acorn_thread (outer_d = outer_d, internal = false, ring = true) { - outer_d = outer_d; - - if (internal) { - outer_ring_d = outer_d+max(thread_size, wall_thickness)+1; - echo ("outer ring = ", outer_ring_d); - ScrewHole (outer_diam=outer_d, height = thread_height, pitch = thread_pitch, tooth_height = thread_tooth_height, tooth_angle = thread_angle, tolerance=internal_thread_tolerance) { - if (ring) cylinder (d = outer_ring_d, h = thread_height); - } - } - - if (!internal) { - difference () { - ScrewThread (outer_diam=outer_d, height = thread_height, pitch = thread_pitch, tooth_height = thread_tooth_height, tooth_angle = thread_angle, tolerance=external_thread_tolerance); - cylinder (d = outer_d-wall_thickness-thread_size-0.01, h = thread_height * 4, center=true); - } - } -} - - -module nut_body (h = base_height, d = outer_d, nub = true) { - translate ([0 ,0, h]) { - intersection () { - union () { - resize ([d, d, h*2]) sphere (d=h*2); - if (nub) { - translate ([0, d/2-wall_thickness/2, -thread_height]) sphere (d=wall_thickness*2, $fs = 0.1); - } - } - translate ([0 ,0, -h/2]) cube ([d*2, d*2, h], center=true); - } - } -} - -module nut () { - difference () { - nut_body (); - translate ([0, 0, wall_thickness + 0.01]) nut_body (d=outer_d-wall_thickness*2, nub=false); - } - - translate ([0, 0, base_height-0.1]) acorn_thread (outer_d = outer_d); -} - - - -$fs = 1; -$fa = 1; - -module cap_keychain (hole_d=3, spacing=15 /*12*/) { - h=100; - translate ([-spacing/2, 0, 0]) cylinder (d=hole_d, h=h, $fs=0.1); - translate ([spacing/2, 0, 0]) cylinder (d=hole_d, h=h, $fs=0.1); -} - -module cap () { - scale_f = outer_d / 171; - difference () { - scale ([scale_f, scale_f, scale_f]) { - difference () { - union () { - translate ([0, 0, -1]) import ("Acorn_Unthreaded/cap_reduced.stl"); - echo ("h = ", thread_height/scale_f); - cylinder (d = 180, h=thread_height/scale_f); - } - translate ([0, 0, -0.51]) cube ([200, 200, 1], center=true); - } - } - cap_keychain (); - acorn_thread (internal = true, ring = false); - } -} - -module gasket (gasket_height=0.9) { - cylinder (d = outer_d, h = gasket_height, center=true); -} - -module nuts () { -//translate ([outer_d+10, 0, 0,]) nut (); -//cap (); -translate ([-(outer_d+10), 0, 0,]) gasket (); -} - -nuts (); - -module print_test () { - translate ([outer_d+thread_size+5, 0, thread_height]) rotate ([180, 0, 0]) acorn_thread (outer_d = outer_d, internal=true); - translate ([0, 0, thread_height]) rotate ([180, 0, 0]) union () { - translate ([0, 0, 0]) cylinder (d=outer_d-wall_thickness, h=thread_height); - translate ([0, 0, -thread_height*3]) cylinder (d=outer_d/3, h=thread_height*3); - acorn_thread (outer_d = outer_d); - } - - -} +// Threads for acorn model +// Copyright (c) 2017 Clinton Ebadi + +use // http://www.thingiverse.com/thing:1686322 + +AUTO_CALCULATE = -1; + +internal_thread_tolerance = 0.3; +external_thread_tolerance = 0.2; +thread_angle = 50; + +module acorn (thread_pitch = 3.0, + thread_size = 2.5, + thread_height = 3.5, + thread_tooth_height = AUTO_CALCULATE, + + inner_d = 24.5, + base_height = AUTO_CALCULATE, + wall_thickness = AUTO_CALCULATE, + outer_d = AUTO_CALCULATE, + + keychain = true) { + + // derived settings + wall_thickness = (wall_thickness == AUTO_CALCULATE) ? thread_size : wall_thickness; + outer_d = (outer_d == AUTO_CALCULATE) ? inner_d + wall_thickness*2 : outer_d; + thread_tooth_height = (thread_tooth_height == AUTO_CALCULATE) ? ((thread_pitch - 0.4 > 0) ? thread_pitch - 0.4 : thread_pitch) : thread_tooth_height; + base_height = (base_height == AUTO_CALCULATE) ? inner_d : base_height; + + + module acorn_thread (outer_d = outer_d, internal = false, ring = true) { + if (internal) { + outer_ring_d = outer_d+max(thread_size, wall_thickness)+1; + echo ("outer ring = ", outer_ring_d); + ScrewHole (outer_diam=outer_d, height = thread_height, pitch = thread_pitch, tooth_height = thread_tooth_height, tooth_angle = thread_angle, tolerance=internal_thread_tolerance) { + if (ring) cylinder (d = outer_ring_d, h = thread_height); + } + } + + if (!internal) { + difference () { + ScrewThread (outer_diam=outer_d, height = thread_height, pitch = thread_pitch, tooth_height = thread_tooth_height, tooth_angle = thread_angle, tolerance=external_thread_tolerance); + cylinder (d = outer_d-wall_thickness-thread_size-0.01, h = thread_height * 4, center=true); + } + } + } + + module nut_body (h = base_height, d = outer_d, nub = false) { + translate ([0 ,0, h]) { + intersection () { + union () { + resize ([d, d, h*2]) sphere (d=h*2); + if (nub) { + translate ([0, d/2-wall_thickness/2, -thread_height]) sphere (d=wall_thickness*2, $fs = 0.1); + } + } + translate ([0 ,0, -h/2]) cube ([d*2, d*2, h], center=true); + } + } + } + + module nut () { + difference () { + nut_body (); + translate ([0, 0, wall_thickness + 0.01]) nut_body (d=outer_d-wall_thickness*2, nub=false); + } + + translate ([0, 0, base_height-0.1]) acorn_thread (outer_d = outer_d); + } + + + module cap_keychain_holes (hole_d=3, spacing=15 /*12*/) { + h=100; + translate ([-spacing/2, 0, 0]) cylinder (d=hole_d, h=h, $fs=0.1); + translate ([spacing/2, 0, 0]) cylinder (d=hole_d, h=h, $fs=0.1); + } + + module cap () { + scale_f = outer_d / 171; + difference () { + scale ([scale_f, scale_f, scale_f]) { + difference () { + union () { + translate ([0, 0, -1]) import ("Acorn_Unthreaded/cap_reduced.stl"); + echo ("h = ", thread_height/scale_f); + cylinder (d = 180, h=thread_height/scale_f); + } + translate ([0, 0, -0.51]) cube ([200, 200, 1], center=true); + } + } + if (keychain) cap_keychain_holes (); + acorn_thread (internal = true, ring = false); + } + } + + module gasket (gasket_height=0.9) { + cylinder (d = outer_d, h = gasket_height, center=true); + } + + module nuts () { + translate ([outer_d+10, 0, 0,]) nut (); + cap (); + translate ([-(outer_d+10), 0, 0,]) gasket (); + } + + nuts (); +} + +$fs = 1; +$fa = 1; + +acorn (); -- 2.20.1