Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to customize tab sizes (d_tabw and d_tabh) + function for multiple equally sized bins #160

Merged
merged 3 commits into from
Feb 16, 2024
Merged
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
54 changes: 44 additions & 10 deletions gridfinity-rebuilt-utility.scad
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module cutEqual(n_divx=1, n_divy=1, style_tab=1, scoop_weight=1) {
cut((i-1)*$gxx/n_divx,(j-1)*$gyy/n_divy, $gxx/n_divx, $gyy/n_divy, style_tab, scoop_weight);
}


// Creates equally divided cylindrical cutouts
//
// n_divx: number of x cutouts
Expand Down Expand Up @@ -89,10 +90,43 @@ module gridfinityInit(gx, gy, h, h0 = 0, l = l_grid, sl = 0) {
// 0:full, 1:auto, 2:left, 3:center, 4:right, 5:none
// 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=1) {

module cut(x=0, y=0, w=1, h=1, t=1, s=1, tab_width=d_tabw, tab_height=d_tabh) {
translate([0,0,-$dh-h_base])
cut_move(x,y,w,h)
block_cutter(clp(x,0,$gxx), clp(y,0,$gyy), clp(w,0,$gxx-x), clp(h,0,$gyy-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, tab_width, tab_height);
}


// cuts equally sized bins over a given length at a specified position
// bins_x: number of bins along x-axis
// bins_y: number of bins along y-axis
// len_x: length (in gridfinity bases) along x-axis that the bins_x will fill
// len_y: length (in gridfinity bases) along y-axis that the bins_y will fill
// pos_x: start x position of the bins (left side)
// pos_y: start y position of the bins (bottom side)
// style_tab: Style of the tab used on the bins
// scoop: Weight of the scoop on the bottom of the bins
// tab_width: Width of the tab on the bins, in mm.
// tab_height: How far the tab will stick out over the bin, in mm. Default tabs fit 12mm labels, but for narrow bins can take up too much space over the opening. This setting allows 'slimmer' tabs for use with thinner labels, so smaller/narrower bins can be labeled and still keep a reasonable opening at the top. NOTE: The measurement is not 1:1 in mm, so a '3.5' value does not guarantee a tab that fits 3.5mm label tape. Use the 'measure' tool after rendering to check the distance between faces to guarantee it fits your needs.
module cutEqualBins(bins_x=1, bins_y=1, len_x=1, len_y=1, pos_x=0, pos_y=0, style_tab=5, scoop=1, tab_width=d_tabw, tab_height=d_tabh) {
// Calculate width and height of each bin based on total length and number of bins
bin_width = len_x / bins_x;
bin_height = len_y / bins_y;

// Loop through each bin position in x and y direction
for (i = [0:bins_x-1]) {
for (j = [0:bins_y-1]) {
// Calculate the starting position for each bin
// Adjust position by adding pos_x and pos_y to shift the entire grid of bins as needed
bin_start_x = pos_x + i * bin_width;
bin_start_y = pos_y + j * bin_height;

// Call the cut module to create each bin with calculated position and dimensions
// Pass through the style_tab and scoop parameters
cut(bin_start_x, bin_start_y, bin_width, bin_height, style_tab, scoop, tab_width=tab_width, tab_height=tab_height);
}
}
}

// 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
Expand Down Expand Up @@ -301,11 +335,11 @@ module cut_move_unsafe(x, y, w, h) {
children();
}

module block_cutter(x,y,w,h,t,s) {
module block_cutter(x,y,w,h,t,s,tab_width=d_tabw,tab_height=d_tabh) {

v_len_tab = d_tabh;
v_len_tab = tab_height;
v_len_lip = d_wall2-d_wall+1.2;
v_cut_tab = d_tabh - (2*r_f1)/tan(a_tab);
v_cut_tab = tab_height - (2*r_f1)/tan(a_tab);
v_cut_lip = d_wall2-d_wall-d_clear;
v_ang_tab = a_tab;
v_ang_lip = 45;
Expand All @@ -329,10 +363,10 @@ module block_cutter(x,y,w,h,t,s) {
translate([0,ylen/2,h_base+h_bot])
rotate([90,0,-90]) {

if (!zsmall && xlen - d_tabw > 4*r_f2 && (t != 0 && t != 5)) {
if (!zsmall && xlen - tab_width > 4*r_f2 && (t != 0 && t != 5)) {
fillet_cutter(3,"bisque")
difference() {
transform_tab(style, xlen, ((xcutfirst&&style==-1)||(xcutlast&&style==1))?v_cut_lip:0)
transform_tab(style, xlen, ((xcutfirst&&style==-1)||(xcutlast&&style==1))?v_cut_lip:0, tab_width)
translate([ycutlast?v_cut_lip:0,0])
profile_cutter(height-h_bot, ylen/2, s);

Expand All @@ -347,7 +381,7 @@ module block_cutter(x,y,w,h,t,s) {
if (t != 0 && t != 5)
fillet_cutter(2,"indigo")
difference() {
transform_tab(style, xlen, ((xcutfirst&&style==-1)||(xcutlast&&style==1))?v_cut_lip:0)
transform_tab(style, xlen, ((xcutfirst&&style==-1)||(xcutlast&&style==1)?v_cut_lip:0), tab_width)
difference() {
intersection() {
profile_cutter(height-h_bot, ylen-extent, s);
Expand Down Expand Up @@ -416,12 +450,12 @@ module transform_main(xlen) {
children();
}

module transform_tab(type, xlen, cut) {
module transform_tab(type, xlen, cut, tab_width=d_tabw) {
mirror([0,0,type==1?1:0])
copy_mirror([0,0,-(abs(type)-1)])
translate([0,0,-(xlen)/2])
translate([0,0,r_f2])
linear_extrude((xlen-d_tabw-abs(cut))/(1-(abs(type)-1))-2*r_f2)
linear_extrude((xlen-tab_width-abs(cut))/(1-(abs(type)-1))-2*r_f2)
children();
}

Expand Down
Loading