From 0199dadead48b1cd79aa5ea3847a13847735e5c4 Mon Sep 17 00:00:00 2001 From: kennetek Date: Sun, 2 Oct 2022 17:35:03 -0700 Subject: [PATCH] reworked file structure - renamed a bunch of stuff to make people's lives hard ig (more because the file hierarchy was really bad and needed improvement to make other dependent modules) - updated README documentation to match new modules - new constants file to clear up clutter in main files - base function now separate from the bin function --- README.md | 76 +++- gridfinity-constants.scad | 48 +++ ...built.scad => gridfinity-rebuilt-bins.scad | 347 ++++++++---------- gridfinity-rebuilt-utility.scad | 181 +++++---- .../gridfinity-spiral-vase.json | 46 --- .../gridfinity-spiral-vase.scad | 113 ++---- 6 files changed, 393 insertions(+), 418 deletions(-) create mode 100644 gridfinity-constants.scad rename gridfinity-rebuilt.scad => gridfinity-rebuilt-bins.scad (56%) delete mode 100644 gridfinity-spiral-vase/gridfinity-spiral-vase.json diff --git a/README.md b/README.md index caef9d0..d7bbe8d 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ A ground-up port (with a few extra features) of the stock [gridfinity](https://w - togglable holes (with togglable supportless printing hole structures) - manual compartment construction (make the most wacky bins imaginable) - togglable lip (if you don't care for stackability) +- dividding bases (if you want a 1.5 unit long bin, for instance) ### Printable Holes The printable holes allow your slicer to bridge the gap inside the countersunk magnet hole (using the technique shown [here](https://www.youtube.com/watch?v=W8FbHTcB05w)) so that supports are not needed. @@ -44,10 +45,63 @@ Parameter | Range | Description `enable_lip` | boolean | toggles the lip at the top of the bin that allows for bin stacking ## Modules -Run these functions inside the *Commands* section of *gridfinity-rebuilt.scad*. +Run these functions inside the *Commands* section of *gridfinity-rebuilt-bins.scad*. -### `gridfinityEqual(n_divx, n_divy, style_tab, enable_scoop)` -Generates the "traditional" bins. It is a utility function that creates evenly distributed compartments. +### `gridfinityInit(gridx, gridy, height, height_internal, length)` +Initializes the top part of the bin (walls and solid section). All bins have to use this module, and have the compartments cut out from it. + +Parameter | Range | Description +--- | ----- | --- +`gridx` | {n>0\|n∈R} | number of grid units along X +`gridy` | {n>0\|n∈R} | number of grid units along Y +`height` | {n>0\|n∈R} | height of the bin, in millimeters (but not exactly). See the `height()` function for more info. +`height_internal` | {n>0\|n∈R} | height of the internal block. Can be lower than bin height to save filament on custom bins. default of 0 means use the calculated height. +`length` | {n>0\|n∈R} | length of one unit of the base. default: 42 (The Answer to the Ultimate Question of Life, the Universe, and Everything.) + +``` +// Example: generate a 3x3x6 bin with a 42mm unit size +gridfinityInit(3, 3, height(6), 0, 42) { + cutEqual(n_divx = 3, n_divy = 3, style_tab = 0, enable_scoop = true); +} +``` + +### `height(gridz, gridz_define, enable_lip, enable_zsnap)` +Calculates the proper height for bins. + +Parameter | Range | Description +--- | ----- | --- +`gridz` | {n>0\|n∈R} | bin height. See bin height information and "gridz_define" below. +`gridz_define` | {n>0\|n∈R} | determine what the variable "gridz" applies to based on your use case. default: 0.
• (0) gridz is the height of bins in units of 7mm increments - Zack's method
• (1) gridz is the internal height in millimeters
• (2) gridz is the overall external height of the bin in millimeters +`enable_lip` | boolean | if you are not stacking the bin, you can disable the top lip to save space. default: true +`enable_zsnap` | boolean | automatically snap the bin size to the nearest 7mm increment. default: true + +``` +// Example: height for a 6 unit high bin +height(6); + +// Example: height for a bin that can fit (at maximum) a 30mm high object inside +height(30, 1, true, false); +``` + +### `gridfinityBase(gridx, gridy, length, div_base_x, div_base_y, style_hole)` +Generates the bases for bins. Has various different hole styles, and can be subdivided. + +Parameter | Range | Description +--- | ----- | --- +`gridx` | {n>0\|n∈R} | number of grid units along X +`gridy` | {n>0\|n∈R} | number of grid units along Y +`length` | {n>0\|n∈R} | length of one unit of the base. default: 42 +`div_base_x` | {n>=0\|n∈Z} | number of divisions per 1 unit of base along the X axis. (default 1, only use integers. 0 means automatically guess the division) +`div_base_y` | {n>=0\|n∈Z} | number of divisions per 1 unit of base along the Y axis. (default 1, only use integers. 0 means automatically guess the division) +`style_hole` | {0, 1, 2, 3} | the style of holes in the bases
• (0) No holes
• (1) Magnet holes only
• (2) Magnet and screw holes - no printable slit
• (3) Magnet and screw holes - with printable slit + +``` +// Example: generate a 3x3 base with a 42mm unit size and clean magnet holes +gridfinityBase(3, 3, 42, 0, 0, 1); +``` + +### `cutEqual(n_divx, n_divy, style_tab, enable_scoop)` +Generates the "traditional" bin cutters. It is a utility function that creates evenly distributed compartments. Parameter | Range | Description --- | ----- | --- @@ -58,13 +112,11 @@ Parameter | Range | Description ``` // Example: this generates 9 compartments in a 3x3 grid, and all compartments have a full tab and a scoop -gridfinityEqual(n_divx = 3, n_divy = 3, style_tab = 0, enable_scoop = true); +gridfinityInit(3, 3, height(6), 0, 42) { + cutEqual(n_divx = 3, n_divy = 3, style_tab = 0, enable_scoop = true); +} ``` -### `gridfinityCustom() {}` - -If you want to get crazy with it, you can take control of your destiny and manually place the compartments. This can be done using this module, which will cut all child objects into the container. There are various modules that are exposed for this purpose. - ### `cut(x, y, w, h, t, s)` Cuts a single compartment into the bin at the provided location with the provided attributes. The coordinate system for compartments originates (0,0) at the bottom left corner of the bin, where 1 unit is the length of 1 base. Positive X and positive Y are in the same direction as the global coordinate system. Parameter | Range | Description @@ -77,10 +129,10 @@ Parameter | Range | Description `s` | boolean | toggles the scoopy bit on the bottom edge that allows easy removal of items, for this specific compartment ``` -// Example: Assuming a gridx of 3 and a gridy of 3 +// Example: // this cuts two compartments that are both 1 wide and 2 high. // One is on the bottom left, and the other is at the top right. -gridfinityCustom() { +gridfinityInit(3, 3, height(6), 0, 42) { cut(0, 0, 1, 2, 0, true); cut(2, 1, 1, 2, 0, true); } @@ -96,10 +148,10 @@ Parameter | Range | Description `h` | {n>0\|n∈R} | Height of the area, in base units (1 unit = 1 `length`) ``` -// Example: assuming gridx of 3 and gridy of 3 +// Example: // cuts a cylindrical hole of radius 5 // hole center is located 1/2 units from the right edge of the bin, and 1 unit from the top -gridfinityCustom() { +gridfinityInit(3, 3, height(6), 0, 42) { cut_move(x=2, y=1, w=1, h=2) { cylinder(r=5, h=100, center=true); } diff --git a/gridfinity-constants.scad b/gridfinity-constants.scad new file mode 100644 index 0000000..a6143d7 --- /dev/null +++ b/gridfinity-constants.scad @@ -0,0 +1,48 @@ + +// height of the base +h_base = 5; +// outside rounded radius of bin +r_base = 4; +// lower base chamfer "radius" +r_c1 = 0.8; +// upper base chamfer "radius" +r_c2 = 2.4; +// bottom thiccness of bin +h_bot = 2.2; +// outside radii 1 +r_fo1 = 8.5; +// outside radii 2 +r_fo2 = 3.2; +// outside radii 3 +r_fo3 = 1.6; + +// screw hole radius +r_hole1 = 1.5; +// magnet hole radius +r_hole2 = 3.25; +// center-to-center distance between holes +d_hole = 26; +// magnet hole depth +h_hole = 2.4; + +// top edge fillet radius +r_f1 = 0.6; +// internal fillet radius +r_f2 = 2.8; + +// width of divider between compartments +d_div = 1.2; +// minimum wall thickness +d_wall = 0.95; +// tolerance fit factor +d_clear = 0.25; + +// height of tab (yaxis, measured from inner wall) +d_tabh = 15.85; +// maximum width of tab +d_tabw = 42; +// angle of tab +a_tab = 36; + +d_wall2 = r_base-r_c1-d_clear*sqrt(2); +d_magic = -2*d_clear-2*d_wall+d_div; diff --git a/gridfinity-rebuilt.scad b/gridfinity-rebuilt-bins.scad similarity index 56% rename from gridfinity-rebuilt.scad rename to gridfinity-rebuilt-bins.scad index 290d747..46216cd 100644 --- a/gridfinity-rebuilt.scad +++ b/gridfinity-rebuilt-bins.scad @@ -1,190 +1,157 @@ -// ===== Info ===== // -/* - IMPORTANT: rendering will be better for analyzing the model if fast-csg is enabled. As of writing, this feature is only available in the development builds and not the official release of OpenSCAD, but it makes rendering only take a couple seconds, even for comically large bins. Enable it in Edit > Preferences > Features > fast-csg - the plane that is the top of the internal bin solid is d_height+h_base above z=0 - the magnet holes can have an extra cut in them to make it easier to print without supports - tabs will automatically be disabled when gridz is less than 3, as the tabs take up too much space - base functions can be found in "gridfinity-rebuilt-base.scad" - examples at end of file - - BIN HEIGHT - the original gridfinity bins had the overall height defined by 7mm increments - a bin would be 7*u millimeters tall - the lip at the top of the bin (3.8mm) added onto this height - The stock bins have unit heights of 2, 3, and 6: - Z unit 2 -> 7*2 + 3.8 -> 17.8mm - Z unit 3 -> 7*3 + 3.8 -> 24.8mm - Z unit 6 -> 7*6 + 3.8 -> 45.8mm - -https://github.com/kennetek/gridfinity-rebuilt-openscad - -*/ - -/**/ -/* [Setup Parameters] */ -$fa = 8; -$fs = 0.25; - -/* [General Settings] */ -// number of bases along x-axis -gridx = 2.5; -// number of bases along y-axis -gridy = 2; -// bin height. See bin height information and "gridz_define" below. -gridz = 6; -// base unit -length = 42; - -/* [Compartments] */ -// DivX Number of x Divisions -divx = 1; -// DivY Number of y Divisions -divy = 1; - -/* [Toggles] */ -// Bottom screw/magnet holes -enable_holes = true; -// Extra cut inside magnet holes for better slicing -enable_hole_slit = true; -// Snap gridx height to nearest 7mm increment -enable_zsnap = false; -// enable upper lip for stacking other bins -enable_lip = true; -// disable the screw part of base holes -enable_screw = true; -// internal fillet for easy part removal -scoop = true; - -/* [Other] */ - -// determine what the variable "gridz" applies to based on your use case -gridz_define = 0; // [0:gridz is the height of bins in units of 7mm increments - Zack's method,1:gridz is the internal height in millimeters, 2:gridz is the overall external height of the bin in millimeters] -// the type of tabs -tab_style = 0; //[0:Full,1:Auto,2:Left,3:Center,4:Right,5:None] - -// overrides internal block height of bin (for solid containers). Leave zero for default height. Units: mm -height_internal = 0; - -// Automatically guess the ideal base dividing values based on gridx and gridy (if they are integers, defaults to 1) -div_base_auto = true; -// number of divisions per 1 unit of base along the X axis. For instance, a value of 3 would make 3 mini-bases per length. (default 1, only use integers) -div_base_x = 1; -// number of divisions per 1 unit of base along the Y axis. For instance, a value of 3 would make 3 mini-bases per length. (default 1, only use integers) -div_base_y = 1; - -// ===== Commands ===== // - -color("tomato") - gridfinityEqual(n_divx = divx, n_divy = divy, style_tab = tab_style, enable_scoop = scoop); - -// ===== Reference Dimensions ===== // -/*[Other Miscellaneous Features]*/ -// height of the base -h_base = 5; -// outside rounded radius of bin -r_base = 4; -// lower base chamfer "radius" -r_c1 = 0.8; -// upper base chamfer "radius" -r_c2 = 2.4; -// bottom thiccness of bin -h_bot = 2.2; -// outside radii 1 -r_fo1 = 8.5; -// outside radii 2 -r_fo2 = 3.2; -// outside radii 3 -r_fo3 = 1.6; - -// screw hole radius -r_hole1 = 1.5; -// magnet hole radius -r_hole2 = 3.25; -// center-to-center distance between holes -d_hole = 26; -// magnet hole depth -h_hole = 2.4; - -// top edge fillet radius -r_f1 = 0.6; -// internal fillet radius -r_f2 = 2.8; - -// width of divider between compartments -d_div = 1.2; -// minimum wall thickness -d_wall = 0.95; -// tolerance fit factor -d_clear = 0.25; - -// height of tab (yaxis, measured from inner wall) -d_tabh = 15.85; -// maximum width of tab -d_tabw = 42; -// angle of tab -a_tab = 36; - -// ===== Include ===== // - -include - - - -// ===== Examples ===== - -// ALL EXAMPLES ASSUME gridx == 3 AND gridy == 3 but some may work with other settings - -// 3x3 even spaced grid -//gridfinityEqual(n_divx = 3, n_divy = 3, style_tab = 0, enable_scoop = true); - -// Compartments can be placed anywhere (this includes non-integer positions like 1/2 or 1/3). The grid is defined as (0,0) being the bottom left corner of the bin, with each unit being 1 base long. Each cut() module is a compartment, with the first four values defining the area that should be made into a compartment (X coord, Y coord, width, and height). These values should all be positive. t is the tab style of the compartment (0:full, 1:auto, 2:left, 3:center, 4:right, 5:none). s is a toggle for the bottom scoop. -/* -gridfinityCustom() { - cut(x=0, y=0, w=1.5, h=0.5, t=5, s=false); - cut(0, 0.5, 1.5, 0.5, 5, false); - cut(0, 1, 1.5, 0.5, 5, false); - - cut(0,1.5,0.5,1.5,5,false); - cut(0.5,1.5,0.5,1.5,5,false); - cut(1,1.5,0.5,1.5,5,false); - - cut(1.5, 0, 1.5, 5/3, 2); - cut(1.5, 5/3, 1.5, 4/3, 4); -}*/ - -// Compartments can overlap! This allows for weirdly shaped compartments, such as this "2" bin. -/* -gridfinityCustom() { - cut(0,2,2,1,5,false); - cut(1,0,1,3,5); - cut(1,0,2,1,5); - cut(0,0,1,2); - cut(2,1,1,2); -}*/ - -// Areas without a compartment are solid material, where you can put your own cutout shapes. using the cut_move() function, you can select an area, and any child shapes will be moved from the origin to the center of that area, and subtracted from the block. For example, a pattern of three cylinderical holes. -/* -gridfinityCustom() { - cut(x=0, y=0, w=2, h=3); - cut(x=0, y=0, w=3, h=1, t=5); - cut_move(x=2, y=1, w=1, h=2) - pattern_linear(x=1, y=3, spacing=length/2) - cylinder(r=5, h=10*d_height, center=true); -}*/ - -// You can use loops as well as the bin dimensions to make different parametric functions, such as this one, which divides the box into columns, with a small 1x1 top compartment and a long vertical compartment below - -/*gridfinityCustom() { - for(i=[0:gridx-1]) { - cut(i,0,1,gridx-1); - cut(i,gridx-1,1,1); - } -}*/ - -// Pyramid scheme bin -/* -gridfinityCustom() { - for (i = [0:gridx-1]) - for (j = [0:i]) - cut(j*gridx/(i+1),gridy-i-1,gridx/(i+1),1,0); -}*/ +include + +// ===== Info ===== // +/* + IMPORTANT: rendering will be better for analyzing the model if fast-csg is enabled. As of writing, this feature is only available in the development builds and not the official release of OpenSCAD, but it makes rendering only take a couple seconds, even for comically large bins. Enable it in Edit > Preferences > Features > fast-csg + the magnet holes can have an extra cut in them to make it easier to print without supports + tabs will automatically be disabled when gridz is less than 3, as the tabs take up too much space + base functions can be found in "gridfinity-rebuilt-utility.scad" + examples at end of file + + BIN HEIGHT + the original gridfinity bins had the overall height defined by 7mm increments + a bin would be 7*u millimeters tall + the lip at the top of the bin (3.8mm) added onto this height + The stock bins have unit heights of 2, 3, and 6: + Z unit 2 -> 7*2 + 3.8 -> 17.8mm + Z unit 3 -> 7*3 + 3.8 -> 24.8mm + Z unit 6 -> 7*6 + 3.8 -> 45.8mm + +https://github.com/kennetek/gridfinity-rebuilt-openscad + +*/ + +/* [Setup Parameters] */ +$fa = 8; +$fs = 0.25; + +/* [General Settings] */ +// number of bases along x-axis +gridx = 2; +// number of bases along y-axis +gridy = 2; +// bin height. See bin height information and "gridz_define" below. +gridz = 6; +// base unit +length = 42; + +/* [Compartments] */ +// number of X Divisions +divx = 1; +// number of y Divisions +divy = 1; + +/* [Toggles] */ +// internal fillet for easy part removal +enable_scoop = true; +// snap gridz height to nearest 7mm increment +enable_zsnap = false; +// enable upper lip for stacking other bins +enable_lip = true; + +/* [Other] */ +// determine what the variable "gridz" applies to based on your use case +gridz_define = 0; // [0:gridz is the height of bins in units of 7mm increments - Zack's method,1:gridz is the internal height in millimeters, 2:gridz is the overall external height of the bin in millimeters] +// the type of tabs +style_tab = 1; //[0:Full,1:Auto,2:Left,3:Center,4:Right,5:None] + +// overrides internal block height of bin (for solid containers). Leave zero for default height. Units: mm +height_internal = 0; + +/* [Base] */ +style_hole = 1; // [0:no holes, 1:magnet holes only, 2: magnet and screw holes - no printable slit, 3: magnet and screw holes - printable slit] +// number of divisions per 1 unit of base along the X axis. (default 1, only use integers. 0 means automatically guess the right division) +div_base_x = 0; +// number of divisions per 1 unit of base along the Y axis. (default 1, only use integers. 0 means automatically guess the right division) +div_base_y = 0; + + + +// ===== Commands ===== // + +color("tomato") { + +gridfinityInit(gridx, gridy, height(gridz, gridz_define, enable_lip, enable_zsnap), height_internal, length) { + + cutEqual(n_divx = divx, n_divy = divy, style_tab = style_tab, enable_scoop = enable_scoop); +} +gridfinityBase(gridx, gridy, length, div_base_x, div_base_y, style_hole); + +} + + +// ===== Examples ===== + +// 3x3 even spaced grid +/* +gridfinityInit(3, 3, height(6), 0, 42) { + cutEqual(n_divx = 3, n_divy = 3, style_tab = 0, enable_scoop = true); +} +gridfinityBase(3, 3, 42, 0, 0, 1); +*/ + +// Compartments can be placed anywhere (this includes non-integer positions like 1/2 or 1/3). The grid is defined as (0,0) being the bottom left corner of the bin, with each unit being 1 base long. Each cut() module is a compartment, with the first four values defining the area that should be made into a compartment (X coord, Y coord, width, and height). These values should all be positive. t is the tab style of the compartment (0:full, 1:auto, 2:left, 3:center, 4:right, 5:none). s is a toggle for the bottom scoop. +/* +gridfinityInit(3, 3, height(6), 0, 42) { + cut(x=0, y=0, w=1.5, h=0.5, t=5, s=false); + cut(0, 0.5, 1.5, 0.5, 5, false); + cut(0, 1, 1.5, 0.5, 5, false); + + cut(0,1.5,0.5,1.5,5,false); + cut(0.5,1.5,0.5,1.5,5,false); + cut(1,1.5,0.5,1.5,5,false); + + cut(1.5, 0, 1.5, 5/3, 2); + cut(1.5, 5/3, 1.5, 4/3, 4); +} +gridfinityBase(3, 3, 42, 0, 0, 1); +*/ + +// Compartments can overlap! This allows for weirdly shaped compartments, such as this "2" bin. +/* +gridfinityInit(3, 3, height(6), 0, 42) { + cut(0,2,2,1,5,false); + cut(1,0,1,3,5); + cut(1,0,2,1,5); + cut(0,0,1,2); + cut(2,1,1,2); +} +gridfinityBase(3, 3, 42, 0, 0, 1); +*/ + +// Areas without a compartment are solid material, where you can put your own cutout shapes. using the cut_move() function, you can select an area, and any child shapes will be moved from the origin to the center of that area, and subtracted from the block. For example, a pattern of three cylinderical holes. +/* +gridfinityInit(3, 3, height(6), 0, 42) { + cut(x=0, y=0, w=2, h=3); + cut(x=0, y=0, w=3, h=1, t=5); + cut_move(x=2, y=1, w=1, h=2) + pattern_linear(x=1, y=3, sx=42/2) + cylinder(r=5, h=1000, center=true); +} +gridfinityBase(3, 3, 42, 0, 0, 1); +*/ + +// You can use loops as well as the bin dimensions to make different parametric functions, such as this one, which divides the box into columns, with a small 1x1 top compartment and a long vertical compartment below +/* +gx = 3; +gy = 3; +gridfinityInit(gx, gy, height(6), 0, 42) { + for(i=[0:gx-1]) { + cut(i,0,1,gx-1); + cut(i,gx-1,1,1); + } +} +gridfinityBase(gx, gy, 42, 0, 0, 1); +*/ + +// Pyramid scheme bin +/* +gx = 4.5; +gy = 4; +gridfinityInit(gx, gy, height(6), 0, 42) { + for (i = [0:gx-1]) + for (j = [0:i]) + cut(j*gx/(i+1),gy-i-1,gx/(i+1),1,0); +} +gridfinityBase(gx, gy, 42, 0, 0, 1); +*/ \ No newline at end of file diff --git a/gridfinity-rebuilt-utility.scad b/gridfinity-rebuilt-utility.scad index 7634ca7..21ec09b 100644 --- a/gridfinity-rebuilt-utility.scad +++ b/gridfinity-rebuilt-utility.scad @@ -1,48 +1,45 @@ // UTILITY FILE, DO NOT EDIT // EDIT OTHER FILES IN REPO FOR RESULTS -dht = (gridz_define==0)?gridz*7 : (gridz_define==1)?h_bot+gridz+h_base : gridz-(enable_lip?3.8:0); -d_height = (enable_zsnap?((abs(dht)%7==0)?dht:dht+7-abs(dht)%7):dht)-h_base; -d_wall2 = r_base-r_c1-d_clear*sqrt(2); - -xl = gridx*length-2*d_clear-2*d_wall+d_div; -yl = gridy*length-2*d_clear-2*d_wall+d_div; - -//echo("====="); -//echo(height_total=d_height+h_base+(enable_lip?3.8:0)); -//echo(effective_units=(d_height+h_base)/7); -//echo("====="); +include // ===== User Modules ===== // -// Creates an equally divided gridfinity bin. +// functions to convert gridz values to mm values +function hf (z, d, l) = (d==0)?z*7:(d==1)?h_bot+z+h_base:z-(l?3.8:0); +function height (z,d=0,l=true,s=true) = (s?((abs(hf(z,d,l))%7==0)?hf(z,d,l):hf(z,d,l)+7-abs(hf(z,d,l))%7):hf(z,d,l))-h_base; + +// Creates equally divided cutters for the bin // // n_divx: number of x compartments (ideally, coprime w/ gridx) // n_divy: number of y compartments (ideally, coprime w/ gridy) // set n_div values to 0 for a solid bin // style_tab: tab style for all compartments. see cut() // enable_scoop: scoop toggle for all compartments. see cut() -module gridfinityEqual(n_divx=1, n_divy=1, style_tab=1, enable_scoop=true) { - gridfinityCustom() - translate([0,0,-d_height-h_base]) +module cutEqual(n_divx=1, n_divy=1, style_tab=1, enable_scoop=true) { for (i = [1:n_divx]) for (j = [1:n_divy]) - cut((i-1)*gridx/n_divx,(j-1)*gridy/n_divy, gridx/n_divx, gridy/n_divy, style_tab, enable_scoop); + cut((i-1)*$gxx/n_divx,(j-1)*$gyy/n_divy, $gxx/n_divx, $gyy/n_divy, style_tab, enable_scoop); } -// wrapper module -// DOES NOT CHECK FOR VALID COMPARTMENT STRUCTURE -module gridfinityCustom() { - if (gridz > 0 && dht > 0) { - difference() { - color("firebrick") block_bottom(height_internal==0?d_height-0.1:height_internal); - children(); - } - color("royalblue") block_wall(); +// initialize gridfinity +module gridfinityInit(gx, gy, h, h0 = 0, l) { + $gxx = gx; + $gyy = gy; + $dh = h; + color("tomato") { + difference() { + color("firebrick") + block_bottom(h0==0?$dh-0.1:h0, gx, gy, l); + children(); + } + color("royalblue") + block_wall(gx, gy, l) { + if (enable_lip) profile_wall(); + else profile_wall2(); + } } - color("orange") block_base(); } - // Function to include in the custom() module to individually slice bins // Will try to clamp values to fit inside the provided base size // @@ -56,15 +53,16 @@ module gridfinityCustom() { // Automatic alignment will use left tabs for bins on the left edge, right tabs for bins on the right edge, and center tabs everywhere else. // s: toggle the rounded back corner that allows for easy removal module cut(x=0, y=0, w=1, h=1, t=1, s=true) { + translate([0,0,-$dh-h_base]) cut_move(x,y,w,h) - block_cutter(clp(x,0,gridx), clp(y,0,gridy), clp(w,0,gridx-x), clp(h,0,gridy-y), t, s); + block_cutter(clp(x,0,$gxx), clp(y,0,$gyy), clp(w,0,$gxx-x), clp(h,0,$gyy-y), t, s); } // Translates an object from the origin point to the center of the requested compartment block, can be used to add custom cuts in the bin // See cut() module for parameter descriptions module cut_move(x, y, w, h) { - translate([0,0,height_internal==0?d_height+h_base:height_internal+h_base]) - cut_move_unsafe(clp(x,0,gridx), clp(y,0,gridy), clp(w,0,gridx-x), clp(h,0,gridy-y)) + translate([0,0,height_internal==0?$dh+h_base:height_internal+h_base]) + cut_move_unsafe(clp(x,0,$gxx), clp(y,0,$gyy), clp(w,0,$gxx-x), clp(h,0,$gyy-y)) children(); } @@ -81,13 +79,13 @@ module profile_base() { ]); } -module block_base() { - dbnxt = [for (i=[1:10]) if (abs(gridx*i)%1 < 0.001 || abs(gridx*i)%1 > 0.999) i]; - dbnyt = [for (i=[1:10]) if (abs(gridy*i)%1 < 0.001 || abs(gridy*i)%1 > 0.999) i]; - dbnx = 1/(div_base_auto ? len(dbnxt) > 0 ? dbnxt[0] : 1 : round(div_base_x)); - dbny = 1/(div_base_auto ? len(dbnyt) > 0 ? dbnyt[0] : 1 : round(div_base_y)); - xx = gridx*length-0.5; - yy = gridy*length-0.5; +module gridfinityBase(gx, gy, l, dx, dy, style_hole) { + dbnxt = [for (i=[1:5]) if (abs(gx*i)%1 < 0.001 || abs(gx*i)%1 > 0.999) i]; + dbnyt = [for (i=[1:5]) if (abs(gy*i)%1 < 0.001 || abs(gy*i)%1 > 0.999) i]; + dbnx = 1/(dx==0 ? len(dbnxt) > 0 ? dbnxt[0] : 1 : round(dx)); + dbny = 1/(dy==0 ? len(dbnyt) > 0 ? dbnyt[0] : 1 : round(dy)); + xx = gx*l-0.5; + yy = gy*l-0.5; translate([0,0,h_base]) rounded_rectangle(xx+0.002, yy+0.002, h_bot/1.5, r_fo1/2+0.001); @@ -98,20 +96,19 @@ module block_base() { render() difference() { - pattern_linear2(gridx/dbnx, gridy/dbny, dbnx*length, dbny*length) - block_base_solid(dbnx, dbny); + pattern_linear(gx/dbnx, gy/dbny, dbnx*l, dbny*l) + block_base_solid(dbnx, dbny, l); - - if (enable_holes) - pattern_linear(gridx,gridy,length) - block_base_hole(); + if (style_hole > 0) + pattern_linear(gx, gy, l) + block_base_hole(style_hole); } } } -module block_base_solid(dbnx, dbny) { - xx = dbnx*length-0.05; - yy = dbny*length-0.05; +module block_base_solid(dbnx, dbny, l) { + xx = dbnx*l-0.05; + yy = dbny*l-0.05; translate([0,0,h_base]) mirror([0,0,1]) union() { @@ -127,31 +124,31 @@ module block_base_solid(dbnx, dbny) { } } -module block_base_hole() { +module block_base_hole(style_hole) { pattern_circular(4) - translate([d_hole/2, d_hole/2, 0]) { - union() { - difference() { - cylinder(h = 2*(h_hole+(enable_hole_slit?0.2:0)), r = r_hole2, center=true); - if (enable_hole_slit && enable_screw) - copy_mirror([0,1,0]) - translate([-1.5*r_hole2,r_hole1+0.1,h_hole]) - cube([r_hole2*3,r_hole2*3, 0.4]); - } - if (enable_screw) - cylinder(h = 3*h_base, r = r_hole1, center=true); - } + translate([d_hole/2, d_hole/2, 0]) + union() { + difference() { + cylinder(h = 2*(h_hole+(style_hole==3?0.2:0)), r=r_hole2, center=true); + + if (style_hole==3) + copy_mirror([0,1,0]) + translate([-1.5*r_hole2,r_hole1+0.1,h_hole]) + cube([r_hole2*3,r_hole2*3, 0.4]); } + if (style_hole > 1) + cylinder(h = 3*h_base, r = r_hole1, center=true); + } } module profile_wall_sub_sub() { polygon([ [0,0], [d_wall/2,0], - [d_wall/2,d_height-1.2-d_wall2+d_wall/2], - [d_wall2-d_clear,d_height-1.2], - [d_wall2-d_clear,d_height+h_base], - [0,d_height+h_base] + [d_wall/2,$dh-1.2-d_wall2+d_wall/2], + [d_wall2-d_clear,$dh-1.2], + [d_wall2-d_clear,$dh+h_base], + [0,$dh+h_base] ]); } @@ -160,7 +157,7 @@ module profile_wall_sub() { profile_wall_sub_sub(); color("red") offset(delta = d_clear) - translate([r_base-d_clear,d_height,0]) + translate([r_base-d_clear,$dh,0]) mirror([1,0,0]) profile_base(); square([d_wall,0]); @@ -173,7 +170,7 @@ module profile_wall() { difference() { profile_wall_sub(); difference() { - translate([0, d_height+h_base-d_clear*sqrt(2), 0]) + translate([0, $dh+h_base-d_clear*sqrt(2), 0]) circle(r_base/2); offset(r = r_f1) offset(delta = -r_f1) @@ -186,25 +183,26 @@ module profile_wall() { module profile_wall2() { translate([r_base,0,0]) mirror([1,0,0]) - square([d_wall,d_height]); + square([d_wall,$dh]); } -module block_wall() { +module block_wall(gx, gy, l) { translate([0,0,h_base]) - sweep_rounded(gridx*length-2*r_base-0.5-0.001, gridy*length-2*r_base-0.5-0.001) - if (enable_lip) profile_wall(); - else profile_wall2(); + sweep_rounded(gx*l-2*r_base-0.5-0.001, gy*l-2*r_base-0.5-0.001) + children(); } -module block_bottom( h = 2.2 ) { +module block_bottom( h = 2.2, gx, gy, l ) { translate([0,0,h_base+0.1]) - rounded_rectangle(gridx*length-0.5-d_wall/4, gridy*length-0.5-d_wall/4, h, r_base+0.01); + rounded_rectangle(gx*l-0.5-d_wall/4, gy*l-0.5-d_wall/4, h, r_base+0.01); } module cut_move_unsafe(x, y, w, h) { - translate([(x)*xl/gridx,(y)*yl/gridy,0]) - translate([(-xl+d_div)/2,(-yl+d_div)/2,0]) - translate([(w*xl/gridx-d_div)/2,(h*yl/gridy-d_div)/2,0]) + xx = ($gxx*length+d_magic); + yy = ($gyy*length+d_magic); + translate([(x)*xx/$gxx,(y)*yy/$gyy,0]) + translate([(-xx+d_div)/2,(-yy+d_div)/2,0]) + translate([(w*xx/$gxx-d_div)/2,(h*yy/$gyy-d_div)/2,0]) children(); } @@ -218,16 +216,16 @@ module block_cutter(x,y,w,h,t,s) { v_ang_lip = 45; ycutfirst = y == 0 && enable_lip; - ycutlast = abs(y+h-gridy)<0.001 && enable_lip; + ycutlast = abs(y+h-$gyy)<0.001 && enable_lip; xcutfirst = x == 0 && enable_lip; - xcutlast = abs(x+w-gridx)<0.001 && enable_lip; - zsmall = (d_height+h_base)/7 < 3; + xcutlast = abs(x+w-$gxx)<0.001 && enable_lip; + zsmall = ($dh+h_base)/7 < 3; - ylen = h*yl/gridy-d_div; - xlen = w*xl/gridx-d_div; + ylen = h*($gyy*length+d_magic)/$gyy-d_div; + xlen = w*($gxx*length+d_magic)/$gxx-d_div; - height = d_height; - extent = (s && ycutfirst ? d_wall2-d_wall : 0); + height = $dh; + extent = (s && ycutfirst ? d_wall2-d_wall-d_clear : 0); tab = (zsmall || t == 5) ? (ycutlast?v_len_lip:0) : v_len_tab; ang = (zsmall || t == 5) ? (ycutlast?v_ang_lip:0) : v_ang_tab; cut = (zsmall || t == 5) ? (ycutlast?v_cut_lip:0) : v_cut_tab; @@ -240,7 +238,7 @@ module block_cutter(x,y,w,h,t,s) { fillet_cutter(3,"bisque") difference() { transform_tab(style, xlen, ((xcutfirst&&style==-1)||(xcutlast&&style==1))?v_cut_lip:0) - translate([ycutlast?d_wall2-d_wall:0,0]) + translate([ycutlast?v_cut_lip:0,0]) profile_cutter(height-h_bot, ylen/2, s); if (xcutfirst) @@ -341,7 +339,7 @@ module fillet_cutter(t = 0, c = "goldenrod") { } module profile_cutter(h, l, s) { - scoop = s ? (length*((d_height-2)/7+1)/12-r_f2) : 0; + scoop = s ? (length*(($dh-2)/7+1)/12-r_f2) : 0; translate([r_f2,r_f2]) hull() { if (l-scoop-2*r_f2 > 0) @@ -402,19 +400,12 @@ module copy_mirror(vec=[0,1,0]) { children(); } -module pattern_linear(x = 1, y = 1, spacing = 0) { - translate([-(x-1)*spacing/2,-(y-1)*spacing/2,0]) +module pattern_linear(x = 1, y = 1, sx = 0, sy = 0) { + yy = sy <= 0 ? sx : sy; + translate([-(x-1)*sx/2,-(y-1)*yy/2,0]) for (i = [1:ceil(x)]) for (j = [1:ceil(y)]) - translate([(i-1)*spacing,(j-1)*spacing,0]) - children(); -} - -module pattern_linear2(x = 1, y = 1, xs = 0, ys = 0) { - translate([-(x-1)*xs/2,-(y-1)*ys/2,0]) - for (i = [1:ceil(x)]) - for (j = [1:ceil(y)]) - translate([(i-1)*xs,(j-1)*ys,0]) + translate([(i-1)*sx,(j-1)*yy,0]) children(); } diff --git a/gridfinity-spiral-vase/gridfinity-spiral-vase.json b/gridfinity-spiral-vase/gridfinity-spiral-vase.json deleted file mode 100644 index 3bee464..0000000 --- a/gridfinity-spiral-vase/gridfinity-spiral-vase.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "fileFormatVersion": "1", - "parameterSets": { - "New set 1": { - "$fa": "8", - "$fs": "0.25", - "a_tab": "40", - "bottom_layer": "3", - "d_clear": "0.25", - "d_div": "1.2", - "d_hole": "26", - "d_tabh": "15.85", - "d_wall": "0.94999999999999996", - "enable_funnel": "true", - "enable_holes": "true", - "enable_inset": "true", - "enable_lip": "true", - "enable_pinch": "true", - "enable_scoop_chamfer": "true", - "enable_zsnap": "false", - "gridx": "2", - "gridy": "2", - "gridz": "6", - "gridz_define": "0", - "h_base": "5", - "h_hole": "2.3999999999999999", - "layer": "0.34999999999999998", - "length": "42", - "n_divx": "3", - "nozzle": "0.59999999999999998", - "r_base": "4", - "r_c1": "0.80000000000000004", - "r_c2": "2.3999999999999999", - "r_f1": "0.59999999999999998", - "r_f2": "2.7999999999999998", - "r_fo1": "7.5", - "r_fo2": "3.2000000000000002", - "r_fo3": "1.6000000000000001", - "r_hole1": "1.5", - "r_hole2": "3.25", - "style_base": "0", - "style_tab": "0", - "type": "1" - } - } -} diff --git a/gridfinity-spiral-vase/gridfinity-spiral-vase.scad b/gridfinity-spiral-vase/gridfinity-spiral-vase.scad index 82d46b9..5b37654 100644 --- a/gridfinity-spiral-vase/gridfinity-spiral-vase.scad +++ b/gridfinity-spiral-vase/gridfinity-spiral-vase.scad @@ -1,3 +1,5 @@ +include <../gridfinity-rebuilt-utility.scad> + /* [Special Variables] */ $fa = 8; $fs = 0.25; @@ -24,7 +26,6 @@ layer = 0.35; // number of base layers on build plate bottom_layer = 3; - /* [General Settings] */ // number of bases along x-axis @@ -65,69 +66,25 @@ style_tab = 0; // [0:continuous, 1:broken, 2:auto, 3:right, 4:center, 5:left, 6: // where to put X cutouts for attaching bases style_base = 0; // [0:all, 1:corners, 2:edges, 3:auto, 4:none] - - -/* [Miscellaneous] */ - -// height of the base -h_base = 5; -// outside rounded radius of bin -r_base = 4; -// lower base chamfer "radius" -r_c1 = 0.8; -// upper base chamfer "radius" -r_c2 = 2.4; - -// wall outside radius -r_fo1 = 7.5; -// upper base outside radius -r_fo2 = 3.2; -// lower base outside radius -r_fo3 = 1.6; - -// screw hole radius -r_hole1 = 1.5; -// magnet hole radius -r_hole2 = 3.25; -// center-to-center distance between holes -d_hole = 26; -// magnet hole depth -h_hole = 2.4; - -// top edge fillet radius -r_f1 = 0.6; -// internal fillet radius -r_f2 = 2.8; - -// width of divider between compartments -d_div = 1.2; -// minimum wall thickness -d_wall = 0.95; -// tolerance fit factor -d_clear = 0.25; - -// height of tab (yaxis, measured from inner wall) -d_tabh = 15.85; -// maximum width of tab -d_tabw = length; + // tab angle a_tab = 40; // ===== Include ===== // -include <../gridfinity-rebuilt-utility.scad> // ===== Constants ===== // -bottom = layer*bottom_layer; -h_bot = bottom*2; -x_l = length/2; +d_bottom = layer*bottom_layer; +x_l = length/2; + +dht = (gridz_define==0)?gridz*7 : (gridz_define==1)?h_bot+gridz+h_base : gridz-(enable_lip?3.8:0); +d_height = (enable_zsnap?((abs(dht)%7==0)?dht:dht+7-abs(dht)%7):dht)-h_base; f2c = sqrt(2)*(sqrt(2)-1); // fillet to chamfer ratio me = ((gridx*length-0.5)/n_divx)-nozzle*4-r_fo1-12.7-4; -me2 = min(d_tabw/1.8 + max(0,me), d_tabw/1.25); -m = me2; +m = min(d_tabw/1.8 + max(0,me), d_tabw/1.25); d_ramp = f2c*(length*((d_height-2)/7+1)/12-r_f2)+d_wall2; d_edge = ((gridx*length-0.5)/n_divx-d_tabw-r_fo1)/2; n_st = d_edge < 2 && style_tab != 0 && style_tab != 6 ? 1 : style_tab == 1 && n_divx <= 1? 0 : style_tab; @@ -148,6 +105,7 @@ xFunc = [xAll, xCorner, xEdge, xAuto, xNone]; // ===== Modules ===== // module gridfinityVase() { + $dh = d_height; difference() { union() { difference() { @@ -209,19 +167,19 @@ module gridfinityBaseVase() { difference() { block_base_blank(nozzle*4); translate([0,0,-h_base]) - cube([length*2,length*2,h_bot],center=true); + cube([length*2,length*2,d_bottom*2],center=true); } // magic slice rotate([0,0,90]) - translate([0,0,-h_base+h_bot/2+0.01]) - cube([0.001,length*gridx,d_height+h_bot]); + translate([0,0,-h_base+d_bottom+0.01]) + cube([0.001,length*gridx,d_height+d_bottom*2]); } pattern_circular(4) intersection() { rotate([0,0,45]) - translate([-nozzle,3,-h_base+h_bot/2+0.01]) - cube([nozzle*2,length*gridx,d_height+h_bot]); + translate([-nozzle,3,-h_base+d_bottom+0.01]) + cube([nozzle*2,length*gridx,d_height+d_bottom*2]); block_base_blank(nozzle*4-0.1); } @@ -237,7 +195,7 @@ module gridfinityBaseVase() { cube([length*2, length*2, h_base], center = true); } - linear_extrude(h_bot/2) + linear_extrude(d_bottom) profile_x(0.1); } @@ -263,7 +221,7 @@ module block_base_blank(o = 0) { hull() { rounded_square(length-o-0.05-2*r_c2, r_c2, r_fo2/2); mirror([0,0,1]) - rounded_square(length-o-0.05, h_bot/2, r_fo1/2); + rounded_square(length-o-0.05, d_bottom, r_fo1/2); } } } @@ -339,15 +297,15 @@ module block_divider() { // divider slices difference() { - for (i = [0:(d_height-h_bot/2)/(layer)]) { + for (i = [0:(d_height-d_bottom)/(layer)]) { - if (2*i*layer < d_height-layer/2-h_bot/2-0.1) + if (2*i*layer < d_height-layer/2-d_bottom-0.1) mirror([0,1,0]) - translate([0,(gridy*length/2-0.25-nozzle)/2,layer/2+h_bot/2+2*i*layer]) + translate([0,(gridy*length/2-0.25-nozzle)/2,layer/2+d_bottom+2*i*layer]) cube([nozzle*2-0.01,gridy*length/2-0.25-nozzle,layer],center=true); - if ((2*i+1)*layer < d_height-layer/2-h_bot/2-0.1) - translate([0,(gridy*length/2-0.25-nozzle)/2,layer/2+h_bot/2+(2*i+1)*layer]) + if ((2*i+1)*layer < d_height-layer/2-d_bottom-0.1) + translate([0,(gridy*length/2-0.25-nozzle)/2,layer/2+d_bottom+(2*i+1)*layer]) cube([nozzle*2-0.01,gridy*length/2-0.25-nozzle,layer],center=true); } @@ -397,15 +355,20 @@ module block_vase_base() { // base translate([0,0,-h_base]) { translate([0,0,-0.1]) - color("firebrick") block_bottom(bottom); - color("royalblue") block_wall(); + color("firebrick") + block_bottom(d_bottom, gridx, gridy, length); + color("royalblue") + block_wall(gridx, gridy, length) { + if (enable_lip) profile_wall(); + else profile_wall2(); + } } // magic slice rotate([0,0,90]) mirror([0,1,0]) - translate([0,0,h_bot/2+0.001]) - cube([0.001,length*gridx,d_height+h_bot]); + translate([0,0,d_bottom+0.001]) + cube([0.001,length*gridx,d_height+d_bottom*2]); } // scoop piece @@ -444,17 +407,17 @@ module profile_wall_sub_sub() { module block_inset() { ixx = (gridx*length-0.5)/2; - iyy = d_height/2+h_bot; + iyy = d_height/2+d_bottom*2; izz = sqrt(ixx^2+iyy^2)*tan(40); if (enable_scoop_chamfer && enable_inset) difference() { intersection() { rotate([0,90,0]) - translate([-iyy+h_bot,0,0]) + translate([-iyy+d_bottom*2,0,0]) block_inset_sub(iyy, gridx*length, 45); rotate([0,90,0]) - translate([-iyy+h_bot,0,0]) + translate([-iyy+d_bottom*2,0,0]) rotate([0,90,0]) block_inset_sub(ixx, d_height*2, 45); } @@ -506,14 +469,14 @@ module profile_tabscoop(m) { module block_tabscoop(a=m, b=0, c=0, d=-1) { translate([0,d_tabh*cos(a_tab)-length*gridy/2+0.25+b,0]) difference() { - translate([0,0,-d_tabh*sin(a_tab)*2+d_height+h_bot]) + translate([0,0,-d_tabh*sin(a_tab)*2+d_height+d_bottom*2]) profile_tabscoop(a); translate([-gridx*length/2,-m,-m]) cube([gridx*length,m-d_tabh*cos(a_tab)+0.005+c,d_height*2]); if (d >= 0) - translate([0,0,-d_tabh*sin(a_tab)+d_height+h_bot+m/2+d]) + translate([0,0,-d_tabh*sin(a_tab)+d_height+d_bottom*2+m/2+d]) cube([gridx*length,gridy*length,m],center=true); } } @@ -524,7 +487,7 @@ module transform_vtab(a=0,b=1) { } module transform_vtab_base(a) { - translate([0,d_tabh*cos(a_tab)-length*gridy/2+0.25,-d_tabh*sin(a_tab)+d_height+h_bot]) + translate([0,d_tabh*cos(a_tab)-length*gridy/2+0.25,-d_tabh*sin(a_tab)+d_height+d_bottom*2]) rotate([90,0,270]) linear_extrude(a, center=true) children(); @@ -584,7 +547,7 @@ module block_x() { } module block_x_sub() { - linear_extrude(h_bot+0.01,center=true) + linear_extrude(d_bottom*2+0.01,center=true) offset(0.05) profile_x(); }