// Sheet-metal wall shelf — folded part + flat pattern // Units mm, Z up. Shelf width along X, depth along Y (Y=0 = wall side), rests on Z=0. // All flange heights / depth are OUTSIDE (mold-line) dimensions. /* [Mode] */ mode = "folded"; // [folded, flat] /* [Material] */ thickness = 1.5; // [0.5:0.1:5] bend_radius = 1.5; // inside bend radius [0.5:0.1:10] k_factor = 0.44; // [0.3:0.01:0.5] /* [Shelf] */ width = 300; // [100:1:600] depth = 120; // outside, back face of flange to front face of lip [50:1:300] back_height = 50; // outside, Z=0 to top of back flange [20:1:150] lip_height = 10; // outside, Z=0 to top of front lip [5:1:50] /* [Mounting holes] */ hole_d = 5; // [3:0.5:10] hole_inset = 40; // from each end [10:1:150] hole_above_shelf = 35;// centre height above shelf top surface [10:1:140] /* [Hidden] */ $fn = 64; T = thickness; R = bend_radius; Ro = R + T; BA = (PI/2) * (R + k_factor*T); // 90 deg bend allowance back_flat = back_height - Ro; base_flat = depth - 2*Ro; lip_flat = lip_height - Ro; flat_len = back_flat + base_flat + lip_flat + 2*BA; hole_z = T + hole_above_shelf; // absolute Z of hole centres hole_xs = [hole_inset, width - hole_inset]; module folded() { difference() { union() { // base translate([0, Ro, 0]) cube([width, base_flat, T]); // back flange translate([0, 0, Ro]) cube([width, T, back_flat]); // front lip translate([0, depth - T, Ro]) cube([width, T, lip_flat]); // back bend: centre (y=Ro, z=Ro), occupies y, z< translate([0, depth - Ro, Ro]) quarter(270); } for (x = hole_xs) translate([x, -1, hole_z]) rotate([-90, 0, 0]) cylinder(d = hole_d, h = T + 2); } } // Quarter annulus in the YZ plane, extruded along X, starting at angle a (deg, from +Y toward +Z) module quarter(a) { rotate([90, 0, 90]) // 2D x->Y, y->Z, extrude along X linear_extrude(width) rotate(a) intersection() { difference() { circle(r = Ro); circle(r = R); } square(Ro + 1); } } // Flat pattern: Y=0 is the top edge of the back flange, lip edge at Y=flat_len module flat2d() { difference() { square([width, flat_len]); for (x = hole_xs) translate([x, back_height - hole_z]) circle(d = hole_d); } } module bend_lines() { for (y = [back_flat, back_flat + BA, back_flat + BA + base_flat, back_flat + 2*BA + base_flat]) translate([0, y - 0.05]) square([width, 0.1]); } if (mode == "folded") folded(); else flat2d(); echo(str("BA=", BA, " flat=", width, " x ", flat_len));