diff --git a/featureful_box.scad b/featureful_box.scad new file mode 100644 index 0000000..7cb7e51 --- /dev/null +++ b/featureful_box.scad @@ -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 +$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); +} \ No newline at end of file diff --git a/gridfinity_boxes.scad b/gridfinity_boxes.scad index ca6f24d..fccc3ec 100644 --- a/gridfinity_boxes.scad +++ b/gridfinity_boxes.scad @@ -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) { @@ -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]); } @@ -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. diff --git a/simple_box.scad b/simple_box.scad index b6d03d7..311e41a 100644 --- a/simple_box.scad +++ b/simple_box.scad @@ -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 $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); -} \ No newline at end of file +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); \ No newline at end of file