1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-13 18:24:28 +02:00

fixed head height

This commit is contained in:
Justin Lin
2019-09-21 09:57:57 +08:00
parent cbea572747
commit 6451029b9f

View File

@@ -1,18 +1,22 @@
module connector_peg(radius, spacing = 0.5, height = radius * 2.6, void = false, heads = false) { module connector_peg(radius, height, spacing = 0.5, void = false, heads = false) {
lip_r = radius * 1.2; lip_r = radius * 1.2;
r_diff = lip_r - radius; r_diff = lip_r - radius;
h_unit = height / 7;
d_h_unit = h_unit * 2; h = radius * 2.6;
h_unit = h / 7;
h_head = h_unit * 2;
half_h_unit = h_unit / 2; half_h_unit = h_unit / 2;
total_height = is_undef(height) ? radius * 2.5 : height;
module base(radius, lip_r) { module base(radius, lip_r) {
rotate_extrude() { rotate_extrude() {
translate([0, -d_h_unit + height]) hull() { translate([0, total_height - h_head]) hull() {
square([lip_r - r_diff, d_h_unit]); square([lip_r - r_diff, h_head]);
translate([0, half_h_unit]) translate([0, half_h_unit])
square([lip_r, half_h_unit]); square([lip_r, half_h_unit]);
} }
square([radius, height - d_h_unit]); square([radius, total_height - h_head]);
} }
} }
@@ -20,15 +24,15 @@ module connector_peg(radius, spacing = 0.5, height = radius * 2.6, void = false,
difference() { difference() {
base(radius, lip_r); base(radius, lip_r);
translate([0, 0, d_h_unit]) translate([0, 0, h_head])
linear_extrude(height - r_diff * 2) linear_extrude(total_height)
square([r_diff * 2, lip_r * 2], center = true); square([r_diff * 2, lip_r * 2], center = true);
} }
} }
module peg_void() { module peg_void() {
base(radius + spacing, lip_r + spacing); base(radius + spacing, lip_r + spacing);
translate([0, 0, height]) translate([0, 0, total_height])
linear_extrude(spacing) linear_extrude(spacing)
circle(lip_r); circle(lip_r);
} }
@@ -43,7 +47,7 @@ module connector_peg(radius, spacing = 0.5, height = radius * 2.6, void = false,
} }
if(heads) { if(heads) {
translate([0, 0, height]) { translate([0, 0, h]) {
head(); head();
mirror([0, 0, 1]) head(); mirror([0, 0, 1]) head();
} }