// Material thickness thickness = 3; // Laser kerf kerf = 0.1; // Building block size size = 20; // Correct the slot width for kerf slot_width = thickness - kerf; // Creates a circle with a given size and number of slots module slotted_circle(size, nslots){ // Subtract rectangular areas from circle to create slots difference(){ circle(size); for(i = [0:nslots]){ rotate([0, 0, (360/nslots)*i]) translate([size, 0, 0]) square([size, slot_width], center=true); } } } // Creates a rectangle with given width and length module rounded_square(width, length){ corner_radius = 3; width = width - 2 * corner_radius; length = length - 2 * corner_radius; // Using the convex hull of four circles gives a rectangle with rounded corners hull(){ translate([ width/2, length/2]) circle(corner_radius); translate([-width/2, length/2]) circle(corner_radius); translate([-width/2, -length/2]) circle(corner_radius); translate([ width/2, -length/2]) circle(corner_radius); } } // Creates a rectangle with given dimensions and number of slots module slotted_rectangle(width, length, nslots){ // Submodule to create slots module slot(i){ translate([ width/8 + width/4, start - length/2 + dist*i ]) square([width/4 + 0.1, slot_width], center=true); } start = width/4 + 2*slot_width; dist = (length - 2 * start) / (nslots-1); // Same as for the circle difference(){ rounded_square(width, length); for(i = [0:nslots-1]){ slot(i); rotate([0, 0, 180]) slot(i); } translate([0, length/2]) square([thickness, width/2], center=true); translate([0, -length/2]) square([thickness, width/2], center=true); } } // Creates a number of circular blocks module circles(number, radius, nslots){ for(i = [0:number-1]){ translate([(2 + 2 * radius) * i, 0]) slotted_circle(radius, nslots); } } // Creates a number of rectangular blocks module rectangles(number, width, length, nslots){ for(i = [0:number-1]){ translate([(2 + width) * i, 0]) slotted_rectangle(width, length, nslots); } } // Increase the number of edges making up a circle $fn=20; // Actually create the building blocks circles(5, size/2, 8); translate([0, size + 2]) circles(5, size/2, 8); translate([0, 2 * (size + 2)]) circles(5, size/2, 8); translate([0, -1.5 * size - 2]) rectangles(5, size, 2*size, 3);