$fn=50; RENDER_GF_BAKJE = false; RENDER_GF_GRID = false; MODE = 0; // [0:default,1:deep,2:filled,3:partial filled] WIDTH = 2; DEPTH = 2; HIEGHT = 3; FILL_DEPTH = 0.0; SLOT = 42; NESTING_DEPTH = 5; RESTING_RIM_WIDTH = 2.4; CORNER_RADIUS = 4; CLEARANCE = 0.25; WALL_THIKNESS = 1; module square_rounded(size1, size2, r1, r2, h) { if (is_num(size1)) { size1 = [size1, size1]; size2 = [size2, size2]; square_rounded(size1, size2, r1, r2, h); } else { union() { difference() { translate([0, 0, h/2]) { cube([size1[0]-r1*2, size2[1], h], center=true); cube([size2[0], size1[1]-r1*2, h], center=true); } for(r=[ [ 0, size1[0], size1[1]], [ 90, size1[1], size1[0]], [180, size1[0], size1[1]], [-90, size1[1], size1[0]] ]) rotate([0, 0, r[0]]) translate([-r[1]/2, r[2]/2, 0]) rotate([-45, 0, 0]) cube([r[1], 2*h, 2*h]); } for(r=[ [ 0, size1[0], size1[1]], [ 90, size1[1], size1[0]], [180, size1[0], size1[1]], [-90, size1[1], size1[0]] ]) rotate([0, 0, r[0]]) translate([r[1]/2-r1, r[2]/2-r1]) cylinder(h=h, r1=r1, r2=r2); } } } module gf_bottom() { union() { l3_r = CORNER_RADIUS; l3_h = NESTING_DEPTH; l1_cut = RESTING_RIM_WIDTH; l1_r = l3_r-l1_cut; l0_cut = l1_cut+0.8; l0_r = l3_r-l0_cut; square_rounded( size1=SLOT-2*l0_cut, size2=SLOT-2*l1_cut, r1=l0_r, r2=l1_r, h=0.8+0.001); translate([0, 0, 0.8]) square_rounded( size1=SLOT-2*l1_cut, size2=SLOT-2*l1_cut, r1=l1_r, r2=l1_r, h=l3_h-l1_cut-0.8+0.001); translate([0, 0, l3_h-l1_cut]) square_rounded( size1=SLOT-2*l1_cut, size2=SLOT, r1=l1_r, r2=l3_r, h=l1_cut+0.001); } } module gf_grid_cut(size=[1,1]) { a = CLEARANCE*sin(45); b = CLEARANCE*tan(22.5); c = CLEARANCE/sin(45); union() { l3_r = CORNER_RADIUS; l3_h = NESTING_DEPTH-a; l1_cut = RESTING_RIM_WIDTH-CLEARANCE; l1_r = l3_r-l1_cut; square_rounded( size1=[size[0]*SLOT-2*l1_cut, size[1]*SLOT-2*l1_cut], size2=[size[0]*SLOT-2*l1_cut, size[1]*SLOT-2*l1_cut], r1=l1_r, r2=l1_r, h=l3_h-l1_cut+0.001); translate([0, 0, l3_h-l1_cut]) square_rounded( size1=[size[0]*SLOT-2*l1_cut, size[1]*SLOT-2*l1_cut], size2=[size[0]*SLOT, size[1]*SLOT], r1=l1_r, r2=l3_r, h=l1_cut+0.001); translate([0, 0, l3_h+a/2]) cube([size[0]*SLOT, size[1]*SLOT, a], center=true); } } module gf_bakje_inside_cut(size, fill=0) { connecting_fillet = RESTING_RIM_WIDTH-WALL_THIKNESS-2*CLEARANCE; inside_radius = CORNER_RADIUS-CLEARANCE-WALL_THIKNESS; union() { // bottom shapes translate([0, 0, size[2]*7]) gf_grid_cut(size); // connecting fillet translate([0, 0, size[2]*7+0.001]) rotate([180, 0, 0]) square_rounded( size1=[ SLOT*size[0]-2*RESTING_RIM_WIDTH+2*CLEARANCE, SLOT*size[1]-2*RESTING_RIM_WIDTH+2*CLEARANCE ], size2=[ SLOT*size[0]-2*WALL_THIKNESS-2*CLEARANCE, SLOT*size[1]-2*WALL_THIKNESS-2*CLEARANCE ], r1=CORNER_RADIUS-RESTING_RIM_WIDTH+CLEARANCE, r2=inside_radius, h=connecting_fillet+0.002); // main fill translate([ -SLOT*size[0]/2+CORNER_RADIUS, -SLOT*size[1]/2+CORNER_RADIUS, NESTING_DEPTH+WALL_THIKNESS+fill]) linear_extrude(size[2]*7-NESTING_DEPTH-WALL_THIKNESS-fill-connecting_fillet+0.001) minkowski() { square([ SLOT*size[0]-2*CLEARANCE-inside_radius*2-2*WALL_THIKNESS, SLOT*size[1]-2*CLEARANCE-inside_radius*2-2*WALL_THIKNESS]); circle(r=inside_radius); } } } module gf_bakje_deep_cut() { a = WALL_THIKNESS*sin(45); b = WALL_THIKNESS*tan(22.5); c = WALL_THIKNESS/sin(45); union() { l3_r = CORNER_RADIUS; l3_h = NESTING_DEPTH+c; l1_cut = RESTING_RIM_WIDTH+WALL_THIKNESS; l1_r = l3_r-l1_cut; l1_hd = l3_h-l1_cut-WALL_THIKNESS; translate([0, 0, l3_h-l1_cut+0.001]) rotate([180,0,0]) linear_extrude(height = l1_hd, scale = 1-(2*l1_hd/(SLOT-2*l1_cut))) translate(-[SLOT/2-l1_cut-l1_r, SLOT/2-l1_cut-l1_r]) minkowski() { square([SLOT-2*l1_cut-2*l1_r, SLOT-2*l1_cut-2*l1_r]); circle(r=l1_r); } translate([0, 0, l3_h-l1_cut]) square_rounded( size1=SLOT-2*l1_cut, size2=SLOT, r1=l1_r, r2=l3_r, h=l1_cut+0.001); translate([0, 0, l3_h+a/2]) cube([SLOT, SLOT, a+0.001], center=true); } } GF_BAKJE_MODE_DEFALT=0; GF_BAKJE_MODE_DEEP=1; GF_BAKJE_MODE_FILLED=2; GF_BAKJE_MODE_PARFILL=3; module gf_bakje(size=[1,1,4], mode=GF_BAKJE_MODE_DEFALT, fill_dis=0) { intersection() { difference() { union() { difference() { union() { // bottom shapes translate(-[size[0]-1,size[1]-1]*SLOT/2) for (x = [0:size[0]-1]) for (y = [0:size[1]-1]) translate([x*SLOT, y*SLOT]) gf_bottom(); // main fill translate([ -SLOT*size[0]/2+CORNER_RADIUS, -SLOT*size[1]/2+CORNER_RADIUS, NESTING_DEPTH]) linear_extrude(size[2]*7-CLEARANCE) minkowski() { radius = CORNER_RADIUS-CLEARANCE; square([SLOT*size[0]-2*CLEARANCE-radius*2, SLOT*size[1]-2*CLEARANCE-radius*2]); circle(r=radius); } } fill = (mode==GF_BAKJE_MODE_PARFILL) ? fill_dis : ((mode==GF_BAKJE_MODE_FILLED) ? 10 : 0); gf_bakje_inside_cut(size, fill); if (mode == GF_BAKJE_MODE_DEEP) { intersection() { translate(-[size[0]-1,size[1]-1]*21) for (x = [0:size[0]-1]) for (y = [0:size[1]-1]) translate([x*42, y*42]) gf_bakje_deep_cut(); square_rounded( size1 = [SLOT*size[0]-2*CLEARANCE-2*WALL_THIKNESS, SLOT*size[1]-2*CLEARANCE-2*WALL_THIKNESS], size2 = [SLOT*size[0]-2*CLEARANCE-2*WALL_THIKNESS, SLOT*size[1]-2*CLEARANCE-2*WALL_THIKNESS], r1 = CORNER_RADIUS-CLEARANCE-WALL_THIKNESS, r2 = CORNER_RADIUS-CLEARANCE-WALL_THIKNESS, h = NESTING_DEPTH+WALL_THIKNESS); } } } } } square_rounded( size1 = [SLOT*size[0]-2*CLEARANCE, SLOT*size[1]-2*CLEARANCE], size2 = [SLOT*size[0]-2*CLEARANCE, SLOT*size[1]-2*CLEARANCE], r1 = CORNER_RADIUS-CLEARANCE, r2 = CORNER_RADIUS-CLEARANCE, h = size[2]*7+NESTING_DEPTH); } } module gf_grid(size) { difference() { // block translate([ -SLOT*size[0]/2+CORNER_RADIUS, -SLOT*size[1]/2+CORNER_RADIUS, 0]) linear_extrude(NESTING_DEPTH-0.001) minkowski() { radius = CORNER_RADIUS-CLEARANCE; square([SLOT*size[0]-2*CLEARANCE-radius*2, SLOT*size[1]-2*CLEARANCE-radius*2]); circle(r=radius); } // cut translate(-[size[0]-1,size[1]-1]*SLOT/2) for (x = [0:size[0]-1]) for (y = [0:size[1]-1]) translate([x*SLOT, y*SLOT]) gf_grid_cut(); } } if (RENDER_GF_BAKJE) { // projection(true) // rotate([0, 90, 0]) gf_bakje([WIDTH, DEPTH, HIEGHT], mode=MODE, fill_dis=FILL_DEPTH); } if (RENDER_GF_GRID) { // projection(true) // rotate([0, 90, 0]) gf_grid([WIDTH, DEPTH]); }