1include <BOSL2/std.scad>
2
3pill_dimensions = [21.6,7.64]; // (length;diameter) mm See https://www.lfacapsulefillers.com/capsule-size-chart
4pill_capacity = [2,4];
5
6thickness = 2; //mm (this needs to be at least 2x your nozzle size)
7rounding = pill_dimensions.y/2; //mm
8
9resolution = 100;
10img_res = [502,360];
11
12difference(){
13x1 = [pill_dimensions.x*pill_capacity.x,pill_dimensions.y*pill_capacity.y,pill_dimensions.y/2+thickness*2];
14cuboid(
15 [pill_dimensions.x*pill_capacity.x+thickness*2,pill_dimensions.y*pill_capacity.y+thickness*2,pill_dimensions.y+thickness*3], rounding=rounding,
16 edges=[RIGHT+FRONT,RIGHT+BACK,LEFT+FRONT,LEFT+BACK],
17 anchor=BOT+LEFT+FRONT,
18 $fn=resolution
19);
20translate([thickness,thickness,thickness+pill_dimensions.y/2])
21cuboid(
22 x1, rounding=rounding,
23 edges=[RIGHT+FRONT,RIGHT+BACK,LEFT+FRONT,LEFT+BACK],
24 anchor=BOT+LEFT+FRONT,
25 $fn=resolution
26);
27for (i = [0:pill_capacity.x-1]) {
28for (j = [0:pill_capacity.y-1]) {
29translate([pill_dimensions.x/2,pill_dimensions.y/2,pill_dimensions.y/2])
30translate([pill_dimensions.x*i+thickness,pill_dimensions.y*j+thickness,thickness]) xcyl(d=pill_dimensions.y,h=pill_dimensions.x,rounding=rounding,anchor=CENTER,$fn=resolution);
31}
32}
33translate([0,thickness/2,x1.z+pill_dimensions.y/2])
34cuboid(
35 [x1.x+thickness+thickness/2,x1.y+thickness,thickness/2], rounding=rounding,
36 edges=[RIGHT+FRONT,RIGHT+BACK],
37 anchor=BOT+LEFT+FRONT,
38 $fn=resolution
39);
40}