Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 106 additions & 81 deletions gridfinity_cup_modules.scad
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ module basic_cup(
difference() {
grid_block(num_x, num_y, num_z, magnet_diameter, screw_depth, hole_overhang_remedy=hole_overhang_remedy, half_pitch=half_pitch, box_corner_attachments_only=box_corner_attachments_only);
color("red") partitioned_cavity(num_x, num_y, num_z, withLabel=withLabel,
labelWidth=labelWidth, fingerslide=fingerslide, magnet_diameter=magnet_diameter,
labelWidth=labelWidth, fingerslide=fingerslide, magnet_diameter=magnet_diameter,
screw_depth=screw_depth, floor_thickness=floor_thickness, wall_thickness=wall_thickness,
efficient_floor=efficient_floor, separator_positions=separator_positions, lip_style=lip_style);
efficient_floor=efficient_floor, separator_positions=separator_positions, lip_style=lip_style, half_pitch=half_pitch);
}
}

Expand Down Expand Up @@ -114,7 +114,8 @@ module partitioned_cavity(num_x, num_y, num_z, withLabel=default_withLabel,
labelWidth=default_labelWidth, fingerslide=default_fingerslide,
magnet_diameter=default_magnet_diameter, screw_depth=default_screw_depth,
floor_thickness=default_floor_thickness, wall_thickness=default_wall_thickness,
efficient_floor=default_efficient_floor, separator_positions=[], lip_style=default_lip_style) {
efficient_floor=default_efficient_floor, separator_positions=[], lip_style=default_lip_style,
half_pitch=default_half_pitch) {
// cavity with removed segments so that we leave dividing walls behind
gp = gridfinity_pitch;
outer_wall_th = 1.8; // cavity is this far away from the 42mm 'ideal' block
Expand All @@ -133,7 +134,7 @@ module partitioned_cavity(num_x, num_y, num_z, withLabel=default_withLabel,
difference() {
basic_cavity(num_x, num_y, num_z, fingerslide=fingerslide, magnet_diameter=magnet_diameter,
screw_depth=screw_depth, floor_thickness=floor_thickness, wall_thickness=wall_thickness,
efficient_floor=efficient_floor, lip_style=lip_style);
efficient_floor=efficient_floor, lip_style=lip_style, half_pitch=half_pitch);

if (len(separator_positions) > 0) {
for (i=[0:len(separator_positions)-1]) {
Expand All @@ -156,8 +157,8 @@ module partitioned_cavity(num_x, num_y, num_z, withLabel=default_withLabel,
chamberStart = i == 0 ? 0 : separator_positions[i-1];
chamberWidth = chamberWidths[i];
label_num_x = (labelWidth == 0 || labelWidth > chamberWidth) ? chamberWidth : labelWidth;
label_pos_x = (withLabel == "center" || withLabel == "centerchamber" )? (chamberWidth - label_num_x) / 2
: (withLabel == "right" || withLabel == "rightchamber" )? chamberWidth - label_num_x
label_pos_x = (withLabel == "center" || withLabel == "centerchamber" )? (chamberWidth - label_num_x) / 2
: (withLabel == "right" || withLabel == "rightchamber" )? chamberWidth - label_num_x
: 0 ;

hull() for (i=[0,1, 2])
Expand All @@ -177,7 +178,8 @@ module partitioned_cavity(num_x, num_y, num_z, withLabel=default_withLabel,
module basic_cavity(num_x, num_y, num_z, fingerslide=default_fingerslide,
magnet_diameter=default_magnet_diameter, screw_depth=default_screw_depth,
floor_thickness=default_floor_thickness, wall_thickness=default_wall_thickness,
efficient_floor=default_efficient_floor, lip_style=default_lip_style) {
efficient_floor=default_efficient_floor, lip_style=default_lip_style,
half_pitch=default_half_pitch) {
eps = 0.1;
// I couldn't think of a good name for this ('q') but effectively it's the
// size of the overhang that produces a wall thickness that's less than the lip
Expand All @@ -191,7 +193,7 @@ module basic_cavity(num_x, num_y, num_z, fingerslide=default_fingerslide,
facets = 13;
mag_ht = magnet_diameter > 0 ? 2.4: 0;
m3_ht = screw_depth;
efloor = efficient_floor && magnet_diameter == 0 && screw_depth == 0 && !fingerslide;
efloor = efficient_floor && magnet_diameter == 0 && screw_depth == 0;
seventeen = gridfinity_pitch/2-4;

floorht = max(mag_ht, m3_ht, part_ht) + floor_thickness;
Expand All @@ -203,92 +205,115 @@ module basic_cavity(num_x, num_y, num_z, fingerslide=default_fingerslide,

difference() {
union() {
// cut out inside edge of standard lip
hull() cornercopy(seventeen, num_x, num_y) {
tz(zpoint-eps) cylinder(d=2.3, h=inner_lip_ht+2*eps, $fn=24); // lip
difference() {
union() {
// cut out inside edge of standard lip
hull() cornercopy(seventeen, num_x, num_y) {
tz(zpoint-eps) cylinder(d=2.3, h=inner_lip_ht+2*eps, $fn=24); // lip
}

hull() cornercopy(seventeen, num_x, num_y) {
// create bevels below the lip
if (lip_style3 == "reduced") {
tz(zpoint+1.8) cylinder(d=3.7, h=0.1, $fn=32); // transition from lip (where top of lip would be) ...
// radius increases by (2.3+2*q-3.7)/2 = q-1.4/2 = q-0.7
tz(zpoint-(q-0.7)+1.9-q2) cylinder(d=2.3+2*q, h=q2, $fn=32); // ... to top of thin wall ...
}
else if (lip_style3 == "none") {
tz(zpoint) cylinder(d=2.3+2*q, h=6, $fn=32); // remove entire lip
}
else {// normal
tz(zpoint-0.1) cylinder(d=2.3, h=0.1, $fn=24); // transition from lip ...
tz(zpoint-q-q2) cylinder(d=2.3+2*q, h=q2, $fn=32); // ... to top of thin wall ...
}
// create rounded bottom of bowl (8.5 is high enough to not expose gaps)
tz(2.3/2+q+floorht) sphere(d=2.3+2*q, $fn=32); // .. to bottom of thin wall and floor
tz(2.3/2+q+floorht) mirror([0, 0, 1]) cylinder(d1=2.3+2*q, d2=0, h=1.15+q, $fn=32);
}
}
}

hull() cornercopy(seventeen, num_x, num_y) {
// create bevels below the lip
if (lip_style3 == "reduced") {
tz(zpoint+1.8) cylinder(d=3.7, h=0.1, $fn=32); // transition from lip (where top of lip would be) ...
// radius increases by (2.3+2*q-3.7)/2 = q-1.4/2 = q-0.7
tz(zpoint-(q-0.7)+1.9-q2) cylinder(d=2.3+2*q, h=q2, $fn=32); // ... to top of thin wall ...
}
else if (lip_style3 == "none") {
tz(zpoint) cylinder(d=2.3+2*q, h=6, $fn=32); // remove entire lip

// cut away side lips if num_x is less than 1
if (num_x < 1) {
hull() for (x=[-gridfinity_pitch/2+1.5+0.25+wall_thickness, -gridfinity_pitch/2+num_x*gridfinity_pitch-1.5-0.25-wall_thickness])
for (y=[-10, (num_y-0.5)*gridfinity_pitch-seventeen])
translate([x, y, (floorht+7*num_z)/2])
cylinder(d=3, h=7*num_z, $fn=24);
}

if (efloor) {
if (num_x < 1) {
gridcopy(1, num_y) {
tz(floor_thickness) intersection() {
hull() cornercopy(seventeen-0.5) cylinder(r=1, h=5, $fn=32);
translate([gridfinity_pitch*(-1+num_x), 0, 0]) hull() cornercopy(seventeen-0.5) cylinder(r=1, h=5, $fn=32);
}

// tapered top portion
intersection() {
hull() {
tz(3) cornercopy(seventeen-0.5) cylinder(r=1, h=1, $fn=32);
tz(5) cornercopy(seventeen+2.5-1.15-q) cylinder(r=1.15+q, h=4, $fn=32);
}
translate([gridfinity_pitch*(-1+num_x), 0, 0]) hull() {
tz(3) cornercopy(seventeen-0.5) cylinder(r=1, h=1, $fn=32);
tz(5) cornercopy(seventeen+2.5-1.15-q) cylinder(r=1.15+q, h=4, $fn=32);
}
}
}
}
else { // normal
tz(zpoint-0.1) cylinder(d=2.3, h=0.1, $fn=24); // transition from lip ...
tz(zpoint-q-q2) cylinder(d=2.3+2*q, h=q2, $fn=32); // ... to top of thin wall ...
else {
if (half_pitch) {
// establishes floor
gridcopy(num_x, num_y, half_pitch=half_pitch) hull() tz(floor_thickness) cornercopy(seventeen-0.5-gridfinity_pitch/4) cylinder(r=1, h=5, $fn=32);

// tapered top portion
gridcopy(num_x, num_y, half_pitch=half_pitch) hull() {
tz(3) cornercopy(seventeen-0.5-gridfinity_pitch/4) cylinder(r=1, h=1, $fn=32);
tz(5-(+2.5-1.15-q)) cornercopy(seventeen-gridfinity_pitch/4) cylinder(r=1.15+q, h=4, $fn=32);
}
} else {
// establishes floor
gridcopy(num_x, num_y) hull() tz(floor_thickness) cornercopy(seventeen-0.5) cylinder(r = 1, h = 5, $fn =
32);

// tapered top portion
gridcopy(num_x, num_y) hull() {
tz(3) cornercopy(seventeen-0.5) cylinder(r=1, h=1, $fn=32);
tz(5-(+2.5-1.15-q)) cornercopy(seventeen) cylinder(r=1.15+q, h=4, $fn=32);
}
}
// cleanup floor difference overhangs
hull()
cornercopy(seventeen, num_x, num_y) {
tz(floorht) cylinder(d=2.3+2*q, h=2.3+2*q, $fn=24);
}
}
// create rounded bottom of bowl (8.5 is high enough to not expose gaps)
tz(2.3/2+q+floorht) sphere(d=2.3+2*q, $fn=32); // .. to bottom of thin wall and floor
tz(2.3/2+q+floorht) mirror([0, 0, 1]) cylinder(d1=2.3+2*q, d2=0, h=1.15+q, $fn=32);
}
}

pivot_z_offset = efloor? -floorht+0.7 : 0;
// cut away from the negative to leave behind wall to make it easier to remove piece
pivot_z = 13.6-0.45+floorht-5+seventeen-17;
pivot_z = 13.6-0.45+floorht-5+seventeen-17+pivot_z_offset;
pivot_y = -10;

// rounded inside bottom
if(fingerslide){
for (ai=[0:facets-1])
// normal slide position is -seventeen-1.15 which is the edge of the inner lip
// reduced slide position is -seventeen-1.85 which is the edge of the upper lip
// no lip means we need -gridfinity_pitch/2+1.5+0.25+wall_thickness ?
translate([0, (
lip_style3 == "reduced" ? -0.7
: (lip_style3=="none" ? seventeen+1.15-gridfinity_pitch/2+0.25+wall_thickness
: 0
) ), 0])
if (fingerslide) {
for (ai = [0:facets-1])
// normal slide position is -seventeen-1.15 which is the edge of the inner lip
// reduced slide position is -seventeen-1.85 which is the edge of the upper lip
// no lip means we need -gridfinity_pitch/2+1.5+0.25+wall_thickness ?
translate([0, (
lip_style3 == "reduced" ? -0.7
: (lip_style3 == "none" ? seventeen+1.15-gridfinity_pitch/2+0.25+wall_thickness
: 0
)), 0])
translate([0, pivot_y, pivot_z])
rotate([90*ai/(facets-1), 0, 0])
rotate([90 * ai/(facets-1), 0, 0])
translate([0, -pivot_y, -pivot_z])
translate([-gridfinity_pitch/2, -10-seventeen-1.15, 0])
cube([gridfinity_pitch*num_x, 10, gridfinity_zpitch*num_z+5]);
}
}

// cut away side lips if num_x is less than 1
if (num_x < 1) {
hull() for (x=[-gridfinity_pitch/2+1.5+0.25+wall_thickness, -gridfinity_pitch/2+num_x*gridfinity_pitch-1.5-0.25-wall_thickness])
for (y=[-10, (num_y-0.5)*gridfinity_pitch-seventeen])
translate([x, y, (floorht+7*num_z)/2])
cylinder(d=3, h=7*num_z, $fn=24);
}

if (efloor) {
if (num_x < 1) {
gridcopy(1, num_y) {
tz(floor_thickness) intersection() {
hull() cornercopy(seventeen-0.5) cylinder(r=1, h=5, $fn=32);
translate([gridfinity_pitch*(-1+num_x), 0, 0]) hull() cornercopy(seventeen-0.5) cylinder(r=1, h=5, $fn=32);
}

// tapered top portion
intersection() {
hull() {
tz(3) cornercopy(seventeen-0.5) cylinder(r=1, h=1, $fn=32);
tz(5) cornercopy(seventeen+2.5-1.15-q) cylinder(r=1.15+q, h=4, $fn=32);
}
translate([gridfinity_pitch*(-1+num_x), 0, 0]) hull() {
tz(3) cornercopy(seventeen-0.5) cylinder(r=1, h=1, $fn=32);
tz(5) cornercopy(seventeen+2.5-1.15-q) cylinder(r=1.15+q, h=4, $fn=32);
}
}
}
}
else {
// establishes floor
gridcopy(num_x, num_y) hull() tz(floor_thickness) cornercopy(seventeen-0.5) cylinder(r=1, h=5, $fn=32);

// tapered top portion
gridcopy(num_x, num_y) hull() {
tz(3) cornercopy(seventeen-0.5) cylinder(r=1, h=1, $fn=32);
tz(5-(+2.5-1.15-q)) cornercopy(seventeen) cylinder(r=1.15+q, h=4, $fn=32);
}
translate([-gridfinity_pitch/2, -10-seventeen-1.15, 0])
cube([gridfinity_pitch * num_x, 10, gridfinity_zpitch * num_z+5]);
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions gridfinity_modules.scad
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,18 @@ module gridcopycorners(num_x, num_y, r, onlyBoxCorners = false) {

// similar to quadtranslate but expands to extremities of a block
module cornercopy(r, num_x=1, num_y=1) {
for (xx=[-r, gridfinity_pitch*(num_x-1)+r]) for (yy=[-r, gridfinity_pitch*(num_y-1)+r])
for (xx=[-r, gridfinity_pitch*(num_x-1)+r]) for (yy=[-r, gridfinity_pitch*(num_y-1)+r])
translate([xx, yy, 0]) children();
}


// make repeated copies of something(s) at the gridfinity spacing of 42mm
module gridcopy(num_x, num_y) {
for (xi=[1:num_x]) for (yi=[1:num_y]) translate([gridfinity_pitch*(xi-1), gridfinity_pitch*(yi-1), 0]) children();
module gridcopy(num_x, num_y, half_pitch=default_half_pitch) {
if (half_pitch) {
for (xi=[1:num_x*2]) for (yi=[1:num_y*2]) translate([gridfinity_pitch/2*(xi-1.5), gridfinity_pitch/2*(yi-1.5), 0]) children();
} else {
for (xi=[1:num_x]) for (yi=[1:num_y]) translate([gridfinity_pitch*(xi-1), gridfinity_pitch*(yi-1), 0]) children();
}
}