// Gorilla Pit Furniture: Twin Bed (Single or Bunk) // Frame bed, made out of 2x4 & 2x6, with underbed storage // Ezra Reynolds // Ezra_Reynolds@signalcenters.org // Version History: // 2019-12-29 - v1.0 - First basic version // 2020-11-15 - v1.1 - Code Cleanup, Better Documentation // Goals: // Create durable bed that could be used in a bunkbed or single configuration // ================= CONSTANTS ========================= inch = 25.4; thick = 1.5*inch; board24 = [thick, 3.5*inch, "2x4"]; board26 = [thick, 5.5*inch, "2x6"]; // ================= PARAMETERS ======================== mattress = [38*inch, 75*inch]; bed = [mattress.x+inch, mattress.y+inch]; clearance1 = 14*inch; // Clearance under bed slats = 7; // Slats under mattress decorations = false; // Show mattress and storage placeholders (true/false) bunkbed = true; // Single bed = true, Bunk Bed = false // Additional Bunk Bed Parameters clearance2 = 35.25*inch; // Clearance from top of lower rail to upper rail riser = 10*inch; // Height of top riser rungs = 4; // Number of ladder rungs // --------------- Calculated Values --------------- //Total Height height = clearance1 + board26.y * 2 + clearance2 + board26.y + riser; // Gap around Frame (so that single bed supports will fit) frame_gap = board24.y + inch; // Slate Separation slat_separation = ((bed.y - frame_gap*2) - board24.y) / (slats-1); // Ladder Rung Gap rung_gap = (clearance2 - rungs*board24.y) / (rungs + 1); // =================== MODULES ========================= module board (type, length, vertical=false) { // Create a board, given a board type, a length, and if if is "horizontal" or "vertical" // Based on vertical, determine size size = [(vertical ? type[1]:type[0]), (vertical ? type[0] : type[1])]; cube ([length, size[1], size[0]]); echo (str("BOM: BOARD: ", type[2], ", ", length/25.4, " inches")); // Bill of Materials } // end module board() // ---------------------------------------------------- module frame() { // Create the basic support for a mattress echo (str("BOM: FRAME: (Interior size = ", bed.x/inch, "\" x ", bed.y/inch, "\")")); // Rail #1 echo ("BOM: RAILS"); color ("red") { translate ([0, 0, 0]) rotate ([0, 0, 90]) board (board26, bed.y, true); translate ([bed.x+thick, 0, 0]) rotate ([0, 0, 90]) board (board26, bed.y, true); } // End Caps echo ("BOM: END CAPS"); translate ([-thick, -thick, 0]) color ("gold") board (board26, bed.x+thick*2, true); translate ([-thick, bed.y, 0]) color ("gold") board (board26, bed.x+thick*2, true); // Slats echo ("BOM: SLATS"); echo (str("BOM: ", slats, ", slats, edge-to-edge distance=", slat_separation/inch, " inches")); for (i = [0 : slats - 1]) translate ([0, (slat_separation)*i + frame_gap+board24.y, 0]) rotate ([90,0,0]) color ("green") board (board24, bed.x, true); // BOM: Screws echo ("BOM: 4\" screws: " , 12 + slats*4); // Decoration: Mattress if (decorations) translate ([(bed.x-mattress.x)/2, (bed.y-mattress.y)/2, board24.y]) color("LightYellow") cube ([mattress.x, mattress.y, 8*inch]); } *!frame(); // Remove * to test module excusively // ---------------------------------------------------- module vertical_bunk_support() { // Create Vertical Upright Support for Bunk Bed rotate ([0,0, -180]) translate ([thick, 0,0]) { // Main Rails echo ("BOM: Vertical Rails"); translate ([0, thick, 0]) rotate ([0,-90,90]) color ("purple") board (board26, height, true); translate ([-thick, 0, 0]) rotate ([0,-90,0]) color ("gray") board (board26, height, true); // First Spacers echo ("BOM: Lower Rail Spacers"); translate ([-thick,0,0]) rotate ([0,-90,90]) color ("tan") board (board24, clearance1, true); translate ([-thick*2,-thick,0]) rotate ([0,-90,0]) color ("brown") board (board24, clearance1, true); // Second Spacer echo ("BOM: Second Spacer"); translate ([-thick,0, clearance1+board26.y]) rotate ([0,-90,90]) board (board24, clearance2, true); // Slat Holder echo ("BOM: Ladder Spacers"); for (i = [0:rungs]) { translate ([-thick*2, -thick, clearance1 + board26.y + (board24.y + rung_gap)*i]) rotate ([0,-90,0]) color("cyan") board (board24, rung_gap, true); } } echo (str("BOM: 4\" screws (main uprights, every 5 inches): ", ceil(height / (5*inch)))); echo (str("BOM: 2.5\" screws (ladder supports): ", (rungs+1)*2)); echo (str("BOM: 2.5\" screws (lower bed supports): ", 8)); echo (str("BOM: 2.5\" screws (upper bed support, every 5 inches): ", ceil(clearance2/(5*inch)))); } *!vertical_bunk(); // Remove * to test module excusively // ---------------------- module vertical_bunk_assembly() { // Create End Assembly for Bunk Bed (Uprights and Ladder) // Uprights vertical_bunk_support(); translate ([bed.x + thick*2, 0, 0]) mirror ([1, 0, 0]) vertical_bunk_support(); // Ladder Slats echo ("BOM: Ladder Rungs"); for (i= [0: rungs-1]) translate ([board24.x, 0, clearance1 + board26.y + ((board24.y+rung_gap)*i) + rung_gap]) color ("DeepPink") board(board24, bed.x, true); echo (str("BOM: 2.5\" Screws: ", ceil (rungs*4))); } *!vertical_bunk_assembly(); // Remove * to test module excusively // --------------------------------- module single_leg() { // Create a stand for the leg (single bed) echo ("BOM: Leg Support"); translate ([-thick, 0, 0]) rotate ([0,-90, -90]) color ("purple") board (board26, clearance1+board26.y, true); translate ([board26.y -thick, -thick, 0]) rotate ([0,-90, 0]) color ("cyan") board (board26, clearance1 + board26.y, true); translate ([0, thick, 0]) rotate ([0,-90, -90]) color ("lime") board (board24, clearance1, true); translate ([0, thick, 0]) rotate ([0,-90, -180]) color ("deeppink") board (board24, clearance1, true); echo (str("BOM: 4\" screws: ", 4)); echo (str("BOM: 2.5\" screws: ", 8)); } *!single_leg(); // Remove * to test module excusively // ============= CREATE MODEL ======================== if (bunkbed) { // Bunk Bed // Create Bed Frame translate ([thick, thick, clearance1]) frame(); translate ([thick, thick, clearance1+board26.y+clearance2]) frame(); vertical_bunk_assembly(); translate ([0, bed.y+thick*2, 0]) mirror ([0,1,0]) vertical_bunk_assembly(); // Safety rail translate ([thick, 0, height-board24.y]) rotate ([0,0,90]) color ("lime") board(board24, bed.y + thick*2, true); echo (str("BOM: 2.5\" Screws: ", 4)); // Decoration: Sample 14" cube for underbed storage if(decorations) color ("yellow") translate ([0, 300, 0]) cube ([clearance1, clearance1, clearance1]); } else { // Single Bed // Create Bed Frame translate ([thick, thick, clearance1]) frame(); single_leg(); translate ([bed.x+thick*2, 0, 0]) mirror([1,0,0]) single_leg(); translate ([0, bed.y+thick*2,0]) mirror([0,1,0]) { single_leg(); translate ([bed.x+thick*2, 0, 0]) mirror([1,0,0]) single_leg(); } } // END OF FILE. S.D.G.