Skip to content

Commit

Permalink
Added labelling tab option. (#18)
Browse files Browse the repository at this point in the history
Also split example file into two parts: simple_box, featureful_box.
  • Loading branch information
chmarr authored May 6, 2023
1 parent 034d34b commit 67c073a
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 45 deletions.
62 changes: 62 additions & 0 deletions featureful_box.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Gridfinity Module Generator
// Copyright 2023 Chris Cogdon
// Licence: CC-BY-SA-4.0
// https://www.github.com/chmarr/gridfinity-boxes
//
// This template creates a simple box of a given size.
//
// Note, all "heights" in the parameters use the bottom of the box as zero.

// The number of Gridfinity squares for this box
gridfinity_count = [3, 2];

// The height of the box walls, not including the stacking lip.
// If a stacking rim is selected, this will be rounded up to a multiple of 7
box_height=35;

// Wether or not to add a stacking lip.
add_stacking_lip=true;

// The radius of the curve added to the internal surface.
internal_radius=8;

// On which sides to place curves. [right, back, left, front].
internal_radius_sides = [false, true, false, true];

// How many dividers in the X and Y dimension. [0,0] means no dividers.
dividers = [0, 0];

// If there are dividers, what should the wall thickness be.
divider_thickness = 1.2;

// If not "undef", what should the height of the dividers be, measured from the internal bottom.
// If "undef", the dividers will be to the top of the box (minus the stacking lip).
divider_height = undef;

// 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;

// Width of a labelling tab at the top-rear of the box. Use '0' for no label.
label_width=0;

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

use <gridfinity_boxes.scad>
$fn = 40;
divider_height_ = divider_height == undef ? box_height - 7 : divider_height;

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_dividers(gridfinity_count, dividers, divider_thickness, divider_height_, internal_radius, sides=internal_radius_sides);
gridfinity_label_tab(gridfinity_count, label_width, box_height-7);
if(add_stacking_lip){
gridfinity_stacking_lip(gridfinity_count, adjusted_box_height);
}
29 changes: 25 additions & 4 deletions gridfinity_boxes.scad
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ module isolated_fillet(radius, length) {
}
}

module isolated_chamfer(width, length) {
linear_extrude(length) polygon([[0,0],[width,0],[0,width]]);
}

// Translates an internal construction with front left corner at [0,0,0] to
// our final reference.
module internal_translate(z_offset=module_unit_height) {
Expand Down Expand Up @@ -379,19 +383,19 @@ module gridfinity_wall(count, height, z_offset=module_unit_height) {
// divider_thickness - the thickness of the divider walls
// divider_height - the height of the divider measured from the internal bottom

module gridfinity_internal_dividers(count, divider_count, divider_thickness, divider_height, radius, sides=[1,1,1,1], z_offset=module_unit_height) {
module gridfinity_internal_dividers(count, divider_count, divider_thickness=1.2, divider_height, radius, sides=[1,1,1,1], z_offset=module_unit_height) {
id = internal_dim(count);
step = [
(id.x + divider_thickness) / (divider_count.x+1),
(id.y + divider_thickness) / (divider_count.y+1)
];
internal_translate() {
if(divider_count.x > 0) {
internal_translate(z_offset=z_offset) {
if(divider_count.x > 0 && divider_height>0) {
for(ix = [1: divider_count.x]) {
translate([ix*step.x - divider_thickness, 0, 0]) cube([divider_thickness, id.y, divider_height]);
}
}
if(divider_count.y > 0) {
if(divider_count.y > 0 && divider_height>0) {
for(iy = [1: divider_count.y]) {
translate([0, iy*step.y - divider_thickness, 0]) cube([id.x, divider_thickness, divider_height]);
}
Expand All @@ -416,6 +420,23 @@ module gridfinity_internal_fillets(count, radius, sides=[1,1,1,1], z_offset=modu
gridfinity_internal_dividers(count, divider_count=[0,0], radius=radius, sides=sides, z_offset=z_offset);
}

// gridfinity_label_tab - creates a tab at the top-rear of the box for labelling
// count, z_offset - see Common Parameters above.
// label_width - the width of the label
// label_thickness - the thickness of the label
// label_height - the height of the top face of the label above the internal bottom
module gridfinity_label_tab(count, label_width, label_height, label_thickness=1.0, support_scale=0.2, z_offset=module_unit_height) {
id = internal_dim(count);
if(label_width>0 && label_thickness>0) {
internal_translate(z_offset=z_offset) {
translate([0, id.y-label_width, label_height-label_thickness]) {
cube([id.x, label_width, label_thickness]);
translate([id.x, label_width, 0]) scale([1,1,support_scale]) rotate([0,90,180]) isolated_chamfer(label_width,id.x);
}
}
}
}

// gridfinity_stacking_lip - Adds a fixed height lip to the object to allow other Gridfinity modules
// to rest atop it.
// count, z_offset - see Common Parameters above.
Expand Down
50 changes: 9 additions & 41 deletions simple_box.scad
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,24 @@
// Licence: CC-BY-SA-4.0
// https://www.github.com/chmarr/gridfinity-boxes
//
// This template creates a simple box of a given size.
//
// Note, all "heights" in the parameters use the bottom of the box as zero.
// This template creates a simple box of a given size, with a small internal fillet and holes
// in the base to glue-in magnets. If you want a box with more
// features and options, use "featureful_box.scad".

// The number of Gridfinity squares for this box
gridfinity_count = [3, 2];

// The height of the box walls, not including the stacking lip.
// If a stacking rim is selected, this will be rounded up to a multiple of 7
box_height=35;

// Wether or not to add a stacking lip.
add_stacking_lip=true;

// The radius of the curve added to the internal surface.
internal_radius=8;

// On which sides to place curves. [right, back, left, front].
internal_radius_sides = [false, true, false, true];

// How many dividers in the X and Y dimension. [0,0] means no dividers.
dividers = [0, 0];

// If there are dividers, what should the wall thickness be.
divider_thickness = 1.2;

// If not "undef", what should the height of the dividers be, measured from the internal bottom.
// If "undef", the dividers will be to the top of the box (minus the stacking lip).
divider_height = undef;

// 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;
// The height of the box walls in gridfinity units of 7mm, not including the stacking lip.
gridfinity_box_height=5;

// 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;
divider_height_ = divider_height == undef ? box_height - 7 : divider_height;

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_dividers(gridfinity_count, dividers, divider_thickness, divider_height_, internal_radius, sides=internal_radius_sides);
if(add_stacking_lip){
gridfinity_stacking_lip(gridfinity_count, adjusted_box_height);
}
gridfinity_module_base(gridfinity_count, holes=1);
gridfinity_wall(gridfinity_count, gridfinity_box_height*7 - 7);
gridfinity_internal_fillets(gridfinity_count, radius=5, sides=[false,true,false,true]);
gridfinity_stacking_lip(gridfinity_count, gridfinity_box_height*7 - 7);

0 comments on commit 67c073a

Please sign in to comment.