From e8e42e27b6187931181590b758f2cf8bc724b4c9 Mon Sep 17 00:00:00 2001 From: babayaga Date: Fri, 4 Jul 2025 14:33:22 +0200 Subject: [PATCH] saw cut list gen --- cad/drawers/tools/box_folding_tool.scad | 62 ++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/cad/drawers/tools/box_folding_tool.scad b/cad/drawers/tools/box_folding_tool.scad index d1f3161..ac1f28a 100644 --- a/cad/drawers/tools/box_folding_tool.scad +++ b/cad/drawers/tools/box_folding_tool.scad @@ -19,7 +19,7 @@ Nb_Boxes_V = 2; // [1:10] // View control Folded_View = false; // [true, false] // Use "export" to render all parts separately for STEP conversion -view_mode = "preview"; // ["preview", "export", "dxf"] +view_mode = "preview"; // ["preview", "export", "dxf", "cutplan"] // Note: InnerBox_Width from the screenshot (100) is not used directly. // Instead, the compartment widths are calculated based on TotalWidth, Height, and Nb_Boxes_U/V. @@ -271,6 +271,64 @@ module internal_divider_horizontal_export(length, compartment_u_size) { } } +// --------------------------------------------------------------------- +// Module to generate a markdown cut plan for the operator. +// This version avoids all list manipulation for maximum compatibility. +// --------------------------------------------------------------------- +module generate_cut_plan_text() { + // --- Calculations --- + InnerWidth = TotalWidth - 2 * Height; + InnerLength = TotalLength - 2 * Height; + GrooveDepth = TotalThickness - BaseThickness; + + // --- Markdown Output --- + echo("# Saw Operator Cut Plan"); + echo(str("## Board Dimensions: `", TotalWidth, " x ", TotalLength, " mm`")); + echo(""); + echo("## Specifications"); + echo(str("* **V-Groove Spec:** Depth `", GrooveDepth, " mm`")); + echo(str("* **Slot Spec:** Width `", Slot_Width_Walls, " mm`, Depth `", GrooveDepth, " mm`")); + echo(""); + echo("## Blade Setup"); + echo("* **For V-Grooves:** Set saw blade angle to **45 degrees**."); + echo("* **For Slots:** Set saw blade angle to **0 degrees** (straight up)."); + echo(""); + + // --- Setup 1: Vertical Cuts --- + echo("## SETUP 1: VERTICAL CUTS"); + echo("All distances are from the LEFT edge. Flip board for cuts > 50%."); + echo(""); + echo(str("* `", Height, " mm` -- **V-GROOVE**")); + if (Nb_Boxes_U > 1) { + for (i = [1 : Nb_Boxes_U - 1]) { + pos = Height + i * ((InnerWidth - (Nb_Boxes_U - 1) * Slot_Width_Walls) / Nb_Boxes_U) + i * Slot_Width_Walls; + echo(str("* `", pos, " mm` -- **SLOT**")); + } + } + echo(str("* `", TotalWidth - Height, " mm` -- **V-GROOVE**")); + echo(""); + + // --- Setup 2: Horizontal Cuts --- + echo("## SETUP 2: HORIZONTAL CUTS"); + echo("Rotate board 90 deg. All distances from the NEW LEFT edge."); + echo(""); + echo(str("* `", Height, " mm` -- **V-GROOVE**")); + if (Nb_Boxes_V > 1) { + for (i = [1 : Nb_Boxes_V - 1]) { + pos = Height + i * ((InnerLength - (Nb_Boxes_V - 1) * Slot_Width_Walls) / Nb_Boxes_V) + i * Slot_Width_Walls; + echo(str("* `", pos, " mm` -- **SLOT**")); + } + } + echo(str("* `", TotalLength - Height, " mm` -- **V-GROOVE**")); + + echo(""); + echo("---"); + echo("*End of Plan*"); + + // Generate a tiny invisible cube because OpenSCAD needs to produce some geometry. + cube(0.01); +} + // --------------------------------------------------------------------- // Render the final object // --------------------------------------------------------------------- @@ -279,6 +337,8 @@ if (view_mode == "export") { } else if (view_mode == "dxf") { // Project the 2D unfolded pattern for DXF export projection(cut = true) unfolded_pattern(); +} else if (view_mode == "cutplan") { + generate_cut_plan_text(); } else { if (Folded_View) { folded_box();