Commit 6746ec0c authored by György Kurucz's avatar György Kurucz
Browse files

Put screw_box module in separate file.

parent 55251f75
use <../include/screw.scad>;
/*
R: outside radius
r: inside radius
h: total outside height
w: top wall thickness
g: inside gap
txt: text
txt_size: text size
$mark_cap: generate cap part
$mark_aside: offset generated part
$mark_flat: rotate part to lay flat
*/
module screw_box(R = 10, r = -1, h = 10, w = 1, g = 0,
txt = "", txt_size = 0) {
module flower2(r = 10, v = .2, n = 15) {
function rfn(a) = r - abs(sin(a*n))*v;
polygon([ for (i=[0:0.25:359.9999])
[ cos(i)*rfn(i), sin(i)*rfn(i) ] ]);
}
h2 = h / 2;
_r = r < 0 ? R * 0.9 : r;
P = (h2-w-g)/2;
tol = 0.7;
d_min = metric_screw_d_min(P = P, D_maj = 2*_r,
tol = tol);
module shape() { flower2(r = R, v = R * 0.025); }
module screw(tol = 0) {
intersection() {
translate([0,0,h-w-g])
rotate([180,0,0])
metric_screw(P=P,
D_maj=_r*2,tol=tol,taper=true);
translate([-R,-R,0])
cube([R*2,R*2, h-w]);
}
}
module base() {
intersection() {
union() {
linear_extrude(h2) shape();
screw();
}
corner_r = 6;
minkowski() {
translate([0,0,corner_r])
cylinder(r=R - corner_r, h=h, $fn=70);
sphere(r=corner_r, $fn=50);
}
}
}
module cap() {
difference() {
translate([0,0,h2]) linear_extrude(h2)
shape();
screw(tol = 0.7);
cylinder(d=d_min, h = h-w, $fn=100);
translate([0,0,h-w/2]) linear_extrude(w)
text(txt, halign="center",
valign="center", size=txt_size);
}
}
cap = !is_undef($mark_cap);
flat = !is_undef($mark_flat);
aside = !is_undef($mark_aside);
translate([aside ? 2*R : 0, 0, 0])
if (!cap) { base(); } else {
if (flat) {
translate([0,0,h]) rotate([180,0,0]) cap();
} else { cap(); }
}
}
use <../include/screw.scad>;
use <../include/screw_box.scad>;
include <../include/common_objects.scad>;
module flower2(r = 10, v = .2, n = 15) {
......@@ -11,79 +11,6 @@ s_sd = co_sd_card + [.7, .5, .5];
s_usd = co_usd_card + [.5, .5, .4];
s_ad = [12, 25.1, 2.7] + [.4, .4, .3];
/*function n_parents(s, i = 0) = i < $parent_modules ?
n_parents(s, i + 1) + (parent_module(i) == s ? 1 : 0) :
0;*/
/*
R: outside radius
r: inside radius
h: total outside height
w: top wall thickness
g: inside gap
*/
module screw_box(R = 10, r = -1, h = 10, w = 1, g = 0,
txt = "", txt_size = 0) {
h2 = h / 2;
_r = r < 0 ? R * 0.9 : r;
P = (h2-w-g)/2;
tol = 0.7;
d_min = metric_screw_d_min(P = P, D_maj = 2*_r,
tol = tol);
module shape() { flower2(r = R, v = R * 0.025); }
module screw(tol = 0) {
intersection() {
translate([0,0,h-w-g])
rotate([180,0,0])
metric_screw(P=P,
D_maj=_r*2,tol=tol,taper=true);
translate([-R,-R,0])
cube([R*2,R*2, h-w]);
}
}
module base() {
intersection() {
union() {
linear_extrude(h2) shape();
screw();
}
corner_r = 6;
minkowski() {
translate([0,0,corner_r])
cylinder(r=R - corner_r, h=h, $fn=70);
sphere(r=corner_r, $fn=50);
}
}
}
module cap() {
difference() {
translate([0,0,h2]) linear_extrude(h2)
shape();
screw(tol = 0.7);
cylinder(d=d_min, h = h-w, $fn=100);
translate([0,0,h-w/2]) linear_extrude(w)
text(txt, halign="center",
valign="center", size=txt_size);
}
}
/* cap = n_parents("mark_cap") > 0;
flat = n_parents("mark_flat") > 0;
aside = n_parents("mark_aside") > 0; */
cap = !is_undef($mark_cap);
flat = !is_undef($mark_flat);
aside = !is_undef($mark_aside);
translate([aside ? 2*R : 0, 0, 0])
if (!cap) { base(); } else {
if (flat) {
translate([0,0,h]) rotate([180,0,0]) cap();
} else { cap(); }
}
}
/*module mark_cap() { children(); }
module mark_flat() { children(); }
module mark_aside() { children(); }*/
module screw_box_params() {
screw_box(R = 22.5, h = s_sd.y + 2.5, g = 3,
txt = "SD cards", txt_size = 7.5);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment