moved func to baseplate file, organized features
functions in the utility file should be more applicable to "extension" modules, so the baseplate generation was moved to its file. Removed some constants that should be defined by already existing constants. Altered the base generator function to make an accurate model instead of using a scale.
This commit is contained in:
parent
ee3fac92df
commit
b717689c32
3 changed files with 119 additions and 95 deletions
|
@ -49,24 +49,9 @@ d_magic = -2*d_clear-2*d_wall+d_div;
|
|||
|
||||
// Baseplate constants
|
||||
|
||||
// Baseplate top part height (weigthed=false part)
|
||||
bp_h_top = 4.65;
|
||||
|
||||
// Baseplate bottom part height (part added with weigthed=true)
|
||||
bp_h_bot = 6.4;
|
||||
|
||||
// Baseplate z offset
|
||||
bp_z_offset = 0.1;
|
||||
|
||||
// Baaseplate fitting clearance
|
||||
bp_clear = 0.5;
|
||||
|
||||
// Baseplate countersink hole biggest diameter
|
||||
bp_csink_d1 = 8.5;
|
||||
|
||||
// Baseplate countersink hole height
|
||||
bp_csink_h = 2.5;
|
||||
|
||||
// Baseplate bottom cutout rectangle size
|
||||
bp_cut_size = 21.4;
|
||||
|
||||
|
@ -81,3 +66,15 @@ bp_rcut_length = 4.25;
|
|||
|
||||
// Baseplate bottom cutout rounded thingy depth
|
||||
bp_rcut_depth = 2;
|
||||
|
||||
// countersink diameter for baseplate
|
||||
d_cs = 2.5;
|
||||
|
||||
// radius of cutout for skeletonized baseplate
|
||||
r_skel = 2;
|
||||
|
||||
// baseplate counterbore radius
|
||||
r_cb = 2.75;
|
||||
|
||||
// baseplate counterbore depth
|
||||
h_cb = 3;
|
||||
|
|
|
@ -20,25 +20,107 @@ gridy = 2;
|
|||
// base unit
|
||||
length = 42;
|
||||
|
||||
/* [Base] */
|
||||
style_hole = 1; // [0:no holes, 1:magnet holes only, 2: magnet and screw holes - no printable slit, 3: magnet and screw holes - printable slit, 4: magnet and countersunk screw holes]
|
||||
// number of divisions per 1 unit of base along the X axis. (default 1, only use integers. 0 means automatically guess the right division)
|
||||
div_base_x = 0;
|
||||
// number of divisions per 1 unit of base along the Y axis. (default 1, only use integers. 0 means automatically guess the right division)
|
||||
div_base_y = 0;
|
||||
/* [Styles] */
|
||||
|
||||
/* [Togglles] */
|
||||
// baseplate styles
|
||||
style_plate = 2; // [0: thin, 1:weighted, 2:skeletonized]
|
||||
|
||||
// weigthed baseplate with possibility for magnet / screw holes
|
||||
weigthed = true;
|
||||
// enable magnet hole
|
||||
style_magnet = true;
|
||||
|
||||
// hole styles
|
||||
style_hole = 2; // [0:none, 1:contersink, 2:counterbore]
|
||||
|
||||
// cutout in the bottom for weigthed baseplate only
|
||||
bottom_cutout = true;
|
||||
|
||||
// ===== Commands ===== //
|
||||
|
||||
color("tomato") {
|
||||
color("tomato")
|
||||
gridfinityBaseplate(gridx, gridy, length, style_plate, style_magnet, style_hole);
|
||||
|
||||
baseplate(gridx, gridy, length, div_base_x, div_base_y, style_hole, weigthed, bottom_cutout);
|
||||
// Baseplate modules
|
||||
module gridfinityBaseplate(gridx, gridy, length, sp, sm, sh) {
|
||||
|
||||
off = (sp==0?0:sp==1?bp_h_bot:1+(sm?h_hole:0)+(sh==0?0:sh==1?d_cs:h_cb));
|
||||
|
||||
difference() {
|
||||
translate([0,0,h_base])
|
||||
mirror([0,0,1])
|
||||
rounded_rectangle(gridx*length-0.5, gridy*length-0.5, h_base+off, r_base);
|
||||
|
||||
gridfinityBase(gridx, gridy, length, 1, 1, 0, 0.5, false);
|
||||
|
||||
translate([0,0,h_base-0.6])
|
||||
rounded_rectangle(gridx*length*2, gridy*length*2, h_base*2, r_base);
|
||||
|
||||
pattern_linear(gridx, gridy, length) {
|
||||
if (sm)
|
||||
block_base_hole(1);
|
||||
|
||||
if (sp == 1) {
|
||||
translate([0,0,-off])
|
||||
cutter_weight();
|
||||
} else if (sp == 2) {
|
||||
linear_extrude(10*(h_base+off), center = true)
|
||||
profile_skeleton();
|
||||
}
|
||||
|
||||
if (sh == 1) {
|
||||
pattern_circular(4)
|
||||
translate([d_hole/2, d_hole/2, 0]) {
|
||||
cylinder(r = r_hole1+d_clear, h = 10*(h_base+off), center = true);
|
||||
|
||||
translate([0,0,d_cs-off])
|
||||
mirror([0,0,1])
|
||||
hull() {
|
||||
cylinder(h = d_cs+10, r=r_hole1+d_clear);
|
||||
translate([0,0,d_cs])
|
||||
cylinder(h=d_cs+10, r=r_hole1+d_clear+d_cs);
|
||||
}
|
||||
}
|
||||
} else if (sh == 2) {
|
||||
pattern_circular(4)
|
||||
translate([d_hole/2,d_hole/2,-off]) {
|
||||
cylinder(h=10*(h_base+off), r=r_hole1+d_clear, center=true);
|
||||
difference() {
|
||||
cylinder(h = 2*(h_cb+0.2), r=r_cb, center=true);
|
||||
copy_mirror([0,1,0])
|
||||
translate([-1.5*r_cb,r_hole1+0.1,h_cb])
|
||||
cube([r_cb*3,r_cb*3, 0.4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module cutter_weight(){
|
||||
union() {
|
||||
linear_extrude(bp_cut_depth*2,center=true)
|
||||
square(bp_cut_size, center=true);
|
||||
pattern_circular(4)
|
||||
translate([0,10,0])
|
||||
linear_extrude(bp_rcut_depth*2,center=true)
|
||||
union() {
|
||||
square([bp_rcut_width, bp_rcut_length], center=true);
|
||||
translate([0,bp_rcut_length/2,0])
|
||||
circle(d=bp_rcut_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module profile_skeleton() {
|
||||
l = length-2*r_c2-2*r_c1;
|
||||
minkowski() {
|
||||
difference() {
|
||||
square([l-2*r_skel+2*d_clear,l-2*r_skel+2*d_clear], center = true);
|
||||
pattern_circular(4)
|
||||
translate([d_hole/2,d_hole/2,0])
|
||||
minkowski() {
|
||||
square([l,l]);
|
||||
circle(r_hole2+r_skel+2);
|
||||
}
|
||||
}
|
||||
circle(r_skel);
|
||||
}
|
||||
}
|
|
@ -79,7 +79,7 @@ module profile_base() {
|
|||
]);
|
||||
}
|
||||
|
||||
module gridfinityBase(gx, gy, l, dx, dy, style_hole, block_scale=1, final_cut=true) {
|
||||
module gridfinityBase(gx, gy, l, dx, dy, style_hole, off=0, final_cut=true) {
|
||||
dbnxt = [for (i=[1:5]) if (abs(gx*i)%1 < 0.001 || abs(gx*i)%1 > 0.999) i];
|
||||
dbnyt = [for (i=[1:5]) if (abs(gy*i)%1 < 0.001 || abs(gy*i)%1 > 0.999) i];
|
||||
dbnx = 1/(dx==0 ? len(dbnxt) > 0 ? dbnxt[0] : 1 : round(dx));
|
||||
|
@ -91,15 +91,14 @@ module gridfinityBase(gx, gy, l, dx, dy, style_hole, block_scale=1, final_cut=tr
|
|||
rounded_rectangle(xx+0.002, yy+0.002, h_bot/1.5, r_fo1/2+0.001);
|
||||
|
||||
intersection(){
|
||||
if(final_cut) {
|
||||
if (final_cut)
|
||||
translate([0,0,-1])
|
||||
rounded_rectangle(xx+0.005, yy+0.005, h_base+h_bot/2*10, r_fo1/2+0.001);
|
||||
}
|
||||
|
||||
render()
|
||||
difference() {
|
||||
pattern_linear(gx/dbnx, gy/dbny, dbnx*l, dbny*l)
|
||||
scale([block_scale,block_scale,1])
|
||||
block_base_solid(dbnx, dbny, l);
|
||||
block_base_solid(dbnx, dbny, l, off);
|
||||
|
||||
if (style_hole > 0)
|
||||
pattern_linear(gx, gy, l)
|
||||
|
@ -108,25 +107,26 @@ module gridfinityBase(gx, gy, l, dx, dy, style_hole, block_scale=1, final_cut=tr
|
|||
}
|
||||
}
|
||||
|
||||
module block_base_solid(dbnx, dbny, l) {
|
||||
module block_base_solid(dbnx, dbny, l, o) {
|
||||
xx = dbnx*l-0.05;
|
||||
yy = dbny*l-0.05;
|
||||
oo = (o/2)*(sqrt(2)-1);
|
||||
translate([0,0,h_base])
|
||||
mirror([0,0,1])
|
||||
union() {
|
||||
hull() {
|
||||
rounded_rectangle(xx-2*r_c2-2*r_c1,yy-2*r_c2-2*r_c1, h_base, r_fo3/2);
|
||||
rounded_rectangle(xx-2*r_c2, yy-2*r_c2, h_base-r_c1, r_fo2/2);
|
||||
rounded_rectangle(xx-2*r_c2-2*r_c1+o,yy-2*r_c2-2*r_c1+o, h_base+oo, r_fo3/2);
|
||||
rounded_rectangle(xx-2*r_c2+o, yy-2*r_c2+o, h_base-r_c1+oo, r_fo2/2);
|
||||
}
|
||||
hull() {
|
||||
rounded_rectangle(xx-2*r_c2, yy-2*r_c2,r_c2, r_fo2/2);
|
||||
rounded_rectangle(xx-2*r_c2+o, yy-2*r_c2+o,r_c2+oo, r_fo2/2);
|
||||
mirror([0,0,1])
|
||||
rounded_rectangle(xx, yy, h_bot/2, r_fo1/2);
|
||||
rounded_rectangle(xx+o, yy+o, h_bot/2+oo, r_fo1/2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module block_base_hole(style_hole, cs_z=0) {
|
||||
module block_base_hole(style_hole) {
|
||||
pattern_circular(4)
|
||||
translate([d_hole/2, d_hole/2, 0])
|
||||
union() {
|
||||
|
@ -140,11 +140,6 @@ module block_base_hole(style_hole, cs_z=0) {
|
|||
}
|
||||
if (style_hole > 1)
|
||||
cylinder(h = 3*h_base, r = r_hole1, center=true);
|
||||
|
||||
if (style_hole == 4 && cs_z != 0)
|
||||
translate([0,0,cs_z])
|
||||
cylinder(bp_csink_h, d2=bp_csink_d1, r1=r_hole1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,56 +380,6 @@ module profile_cutter_tab(h, tab, ang) {
|
|||
|
||||
}
|
||||
|
||||
// Baseplate modules
|
||||
module baseplate(gridx, gridy, length, div_base_x, div_base_y, style_hole, weighted, bottom_cutout) {
|
||||
|
||||
scale_factor = (bp_clear / (length /100)) /100 + 1;
|
||||
|
||||
union() {
|
||||
difference(){
|
||||
rounded_rectangle(gridx*length, gridy*length, bp_h_top + bp_z_offset - 0.001, r_base);
|
||||
translate([0,0,-bp_z_offset])
|
||||
|
||||
gridfinityBase(gridx, gridy, length, div_base_x, div_base_y, 0, scale_factor, false);
|
||||
}
|
||||
|
||||
if(weighted) {
|
||||
difference() {
|
||||
translate([0,0,-1*(bp_h_bot - bp_clear)])
|
||||
rounded_rectangle(gridx*length, gridy*length, bp_h_bot, r_base);
|
||||
|
||||
pattern_linear(gridx, gridy, length)
|
||||
union() {
|
||||
if (style_hole != 0) {
|
||||
rotate([180,0,0])
|
||||
block_base_hole(style_hole, bp_h_bot - bp_z_offset - bp_csink_h);
|
||||
}
|
||||
|
||||
if (bottom_cutout) {
|
||||
translate([0,0,-1*(bp_h_bot + bp_z_offset)])
|
||||
bottom_cutout();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module bottom_cutout(){
|
||||
union() {
|
||||
linear_extrude(bp_cut_depth)
|
||||
square(bp_cut_size, center=true);
|
||||
pattern_circular(4)
|
||||
translate([0,10,0])
|
||||
linear_extrude(bp_rcut_depth)
|
||||
union() {
|
||||
square([bp_rcut_width, bp_rcut_length], center=true);
|
||||
translate([0,bp_rcut_length/2,0])
|
||||
circle(d=bp_rcut_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==== Utilities =====
|
||||
|
||||
function clp(x,a,b) = min(max(x,a),b);
|
||||
|
|
Loading…
Reference in a new issue