Skip to content

Commit

Permalink
Added option for "Slide-in" magnet holes. (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
chmarr authored Apr 25, 2023
1 parent c608c2b commit 7b4e7cd
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 13 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ on the expected-to-be-called SCAD modules follows.

There are serveral possible modules to call, specified below with their "signatures":

* `gridfinity_module_base(count, holes=0)`
* `gridfinity_module_base(count, holes=0, hole_width, hole_height, hole_offset=0.2)`
* `gridfinity_wall(count, height, z_offset=module_unit_height)`
* `gridfinity_internal_mass(count, height, z_offset=module_unit_height)`
* `gridfinity_square_bores(count, size, z_offset, repeat=[1,1], top_radius=0, bottom_radius=0, top_sides=[1,1,1,1], bottom_sides=[1,1,1,1])`
Expand All @@ -60,7 +60,10 @@ and the stacking lip will usually appear higher.
### gridfinity_module_base
Creates the container base, including the X x Y inserts and a overall base layer. Always 7mm high. The origin of this and other features
is the bottom-center of the *first* insert.
* *holes* -- Selects to put holes in the bottom of the module, as per spec. 0-No holes. 1-Holes in corners only. 2-Holes everywhere.
* *holes* -- Selects to put holes in the bottom of the module, as per spec. 0-No holes. 1-Holes in corners only. 2-Holes everywhere. 3-Slide-in holes in corners
* *hole_width* -- The width of a slide in hole. Typically very slightly smaller than the magnet to allow it to be wedged in. (Only if holes==3)
* *hole_height* -- The height of a slide in hole. Typically this is slightly larger than the magnet to account for variability. (Only if holes==3)
* *hole_offset* -- The vertical offset of the hole from the bottom. Typically just one or two layer's worth to keep the magnet close to the base magnets. (Only if holes==3. Defaults to 0.2)

### gridfinity_wall
Creates the wall around the outside of the box.
Expand Down
49 changes: 40 additions & 9 deletions gridfinity_boxes.scad
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module_unit_height=7;
module_internal_square = module_side - 2*module_radius_1;
internal_radius = module_radius_3;
internal_side=module_side - 2*(1.9 + 0.7);
hole_offset_from_radius_3 = 4.8;

// ***************************************************************************
// The following functions and modules are not expected to be called directly.
Expand Down Expand Up @@ -108,7 +109,6 @@ module gridfinity_base_hole() {
// A 4-tuple, being these corners [back-right, back-left, front-left, front-right]
module gridfinity_base_holes(corners=[1,1,1,1]) {
// Constants derived_from_spec_sheet
hole_offset_from_radius_3 = 4.8;
offset = module_side/2 - module_radius_1 + module_radius_3 - hole_offset_from_radius_3;
if (corners[0]) {
translate([offset,offset]) gridfinity_base_hole();
Expand Down Expand Up @@ -234,6 +234,26 @@ module gridfinity_single_square_bore(size, top_radius=0, bottom_radius=0, top_si
}
}

// creates an object to remove the mass required to insert a magnet.
module gridfinity_magnet_single_hole(hole_width, hole_height){
slot_length = hole_offset_from_radius_3 - module_radius_3 + module_radius_1;
cylinder(d=hole_width, h=hole_height);
translate([-slot_length-epsilon, -hole_width/2, 0]) cube([slot_length+2*epsilon, hole_width, hole_height]);
}

// creates an object to remove the mass required to insert a magnet at each of the corners
module gridfinity_magnet_holes(count, hole_width, hole_height) {
offset = module_side/2 - module_radius_1 + module_radius_3 - hole_offset_from_radius_3;
// back right
translate([module_spacing*(count.x-1)+offset, module_spacing*(count.y-1)+offset]) rotate([0,0,180])gridfinity_magnet_single_hole(hole_width, hole_height);
// back left
translate([-offset, module_spacing*(count.y-1)+offset]) rotate([0,0,-90]) gridfinity_magnet_single_hole(hole_width, hole_height);
// front left
translate([-offset,-offset]) gridfinity_magnet_single_hole(hole_width, hole_height);
// front right
translate([module_spacing*(count.x-1)+offset, -offset]) rotate([0,0,90]) gridfinity_magnet_single_hole(hole_width, hole_height);
}

// ********************************************************************************************
// The following modules are expected to be called by the user to create the desired container.

Expand All @@ -252,17 +272,28 @@ module gridfinity_single_square_bore(size, top_radius=0, bottom_radius=0, top_si
// along the X and Y axes.
// A "lid" for a container can be created by using just this module.
// count - see Common Parameters above.
// holes - Selects where to put magnet/screw holes. 0-none, 1-corners only, 2-everywhere
// Currently,
module gridfinity_module_base(count, holes=0) {
// holes - Selects where to put magnet/screw holes. 0-none, 1-corners only, 2-everywhere, 3-slide-in holes in corners
// hole_width - Width of slide-in hole (only if holes==3)
// hole_height - Height of slide-in hole (only if holes==3)
// hole_offset - Height of the hole offset from the base (only if holes==3)
module gridfinity_module_base(count, holes=0, hole_width, hole_height, hole_offset=0.2) {
plane_height = module_unit_height - module_base_height;
for(x=[0:count.x-1]) {
for(y=[0:count.y-1]) {
translate([x * module_spacing, y*module_spacing])
gridfinity_insert(corners=determine_hole_corners(count, [x,y], holes));
// if holes==3, we're going to add the slide-in magnet holes as a difference overall
holes_ = holes == 3 ? 0 : holes;
difference() {
union() {
for(x=[0:count.x-1]) {
for(y=[0:count.y-1]) {
translate([x * module_spacing, y*module_spacing])
gridfinity_insert(corners=determine_hole_corners(count, [x,y], holes_));
}
}
gridfinity_module_mass(count, plane_height, module_base_height);
}
if(holes==3) {
translate([0,0,hole_offset]) gridfinity_magnet_holes(count, hole_width, hole_height);
}
}
gridfinity_module_mass(count, plane_height, module_base_height);
}

// gridfinity_internal_mass - creates a solid block bounded by the object's walls.
Expand Down
57 changes: 57 additions & 0 deletions magnet_hole_tester.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Magnet Hole Tester for Gridfinity Module Generator
// Copyright 2023 Chris Cogdon
// Licence: CC-BY-SA-4.0
// https://www.github.com/chmarr/gridfinity-boxes
//
// Creates a model to test various sizes of holes for the Gridfinity-common 6x2mm magnet,
// or magnets of any size by adjusting the parameters below. A "dot" is placed at the
// first, or smallest, hole to ease orientation.

// hole width for the middle hole. Typically the 'ideal' size.
median_hole_width=6.0; // [2.0:0.1:10.0]

// side difference between holes
step_size=0.1; // [0.05:0.01:0.2]

// number of holes. Should be an odd number so that the median_hole_width is the middle hole
number_of_holes=7; // [3:2:15]

// the height of the hole. Since we're intending to squeeze the sides, and that magnet heights are variable, this should be distinctly larger than the magnet height
hole_height=2.2; // [1.0:0.1:5.2]

// the height of the floor
floor_height=0.4; // [0.1:0.05:1.0]

/* [Advanced Options] */
// object depth
object_depth=6; // [5:1:15]

// object height
object_height=6; // [5:1:15]

// inter-hole spacing
interhole_spacing=5; // [2:1:10]

module customizer_stop () {}
epsilon=0.005;


module hole_sampler() {
holes_to_either_side = (number_of_holes-1)/2;
first_hole = median_hole_width - holes_to_either_side * step_size;
object_width = median_hole_width * number_of_holes + interhole_spacing * (number_of_holes+1);

difference() {
cube([object_width, object_depth, object_height]);
translate([interhole_spacing, -epsilon, floor_height])
for(i=[0:number_of_holes-1]) {
hole_size=first_hole + i*step_size;
echo("Hole size:", hole_size)
translate([i*(median_hole_width + interhole_spacing),0,0])
cube([hole_size, object_depth+2*epsilon, hole_height]);
}
translate([2,2,object_height-1+epsilon]) cylinder(h=1, d=1.5, $fn=40);
}
}

hole_sampler();
10 changes: 8 additions & 2 deletions simple_box.scad
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@ internal_radius=10;
// On which sides to place curves. [right, back, left, front].
internal_radius_sides = [false, true, false, true];

// Whether or not to insert holes at the bottom of the box. 0=no holes, 1=corners only, 2=everywhere.
// Whether or not to insert holes at the bottom of the box. 0=no holes, 1=corners only, 2=everywhere, 3-slide-in holes in corners
gridfinity_holes=0;

// Width of slide-in magnet hole (only if gridfinity_holes==3)
gridfinity_hole_width=5.9;

// Height of slide-in magnet hole (only if gridfinity_holes==3)
gridfinity_hole_height=2.2;

// And now the fun stuff.
module customizer_break(){}

use <gridfinity_boxes.scad>
$fn = 40;

gridfinity_module_base(gridfinity_count, holes=gridfinity_holes);
gridfinity_module_base(gridfinity_count, holes=gridfinity_holes, hole_width=gridfinity_hole_width, hole_height=gridfinity_hole_height);
adjusted_box_height = add_stacking_lip ? ceil(box_height/7)*7 : box_height;
gridfinity_wall(gridfinity_count, adjusted_box_height-7);
gridfinity_internal_fillets(gridfinity_count, internal_radius, sides=internal_radius_sides);
Expand Down

0 comments on commit 7b4e7cd

Please sign in to comment.