From d3c45bff2f43e949df2a6739f52a385f41b8fdd4 Mon Sep 17 00:00:00 2001 From: babayaga Date: Fri, 4 Jul 2025 14:33:26 +0200 Subject: [PATCH] saw cut list gen --- cad/drawers/tools/cp.md | 27 +++++++++++++ cad/drawers/tools/generate_cut_plan.sh | 52 ++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 cad/drawers/tools/cp.md create mode 100644 cad/drawers/tools/generate_cut_plan.sh diff --git a/cad/drawers/tools/cp.md b/cad/drawers/tools/cp.md new file mode 100644 index 0000000..2db285e --- /dev/null +++ b/cad/drawers/tools/cp.md @@ -0,0 +1,27 @@ +# Saw Operator Cut Plan +## Board Dimensions: `500 x 500 mm` + +## Specifications +* **V-Groove Spec:** Depth `5 mm` +* **Slot Spec:** Width `8 mm`, Depth `5 mm` + +## Blade Setup +* **For V-Grooves:** Set saw blade angle to **45 degrees**. +* **For Slots:** Set saw blade angle to **0 degrees** (straight up). + +## SETUP 1: VERTICAL CUTS +All distances are from the LEFT edge. Flip board for cuts > 50%. + +* `80 mm` -- **V-GROOVE** +* `254 mm` -- **SLOT** +* `420 mm` -- **V-GROOVE** + +## SETUP 2: HORIZONTAL CUTS +Rotate board 90 deg. All distances from the NEW LEFT edge. + +* `80 mm` -- **V-GROOVE** +* `254 mm` -- **SLOT** +* `420 mm` -- **V-GROOVE** + +--- +*End of Plan* diff --git a/cad/drawers/tools/generate_cut_plan.sh b/cad/drawers/tools/generate_cut_plan.sh new file mode 100644 index 0000000..d7c382f --- /dev/null +++ b/cad/drawers/tools/generate_cut_plan.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# --- generate_cut_plan.sh --- +# Generates a markdown cut plan from an OpenSCAD file. +# This script calls OpenSCAD in a special mode to echo the plan. +# +# Usage: ./generate_cut_plan.sh [output.md] +# If output file is not provided, prints to console. + +# --- Input Validation --- +if [ -z "$1" ]; then + echo "Usage: $0 [output.md]" + echo "Error: Source file not specified." + exit 1 +fi + +SOURCE_FILE="$1" +OUTPUT_FILE="$2" +DUMMY_OUTPUT="cutplan_dummy.stl" # A dummy file to force command-line execution + +# --- OpenSCAD Command --- +# We force a dummy output file with -o to prevent the GUI from launching. +# OpenSCAD prints echo() statements to stderr. We redirect stderr to stdout (2>&1), +# then use grep to filter for only the lines starting with "ECHO:", +# and then use sed to remove the prefix and surrounding quotes for a clean output. +CUTPLAN_CONTENT=$(openscad \ + -o "$DUMMY_OUTPUT" \ + -D "view_mode=\"cutplan\"" \ + "$SOURCE_FILE" \ + 2>&1 | grep "ECHO:" | sed 's/ECHO: "//;s/"$//') + +# Check the exit status of the openscad command. +if [ ${PIPESTATUS[0]} -ne 0 ]; then + echo "" + echo "Error: OpenSCAD command failed." + rm -f "$DUMMY_OUTPUT" # Clean up dummy file on failure + exit 1 +fi + +# Clean up the dummy file +rm -f "$DUMMY_OUTPUT" + +# --- Output the result --- +if [ -z "$OUTPUT_FILE" ]; then + echo "" + echo "--- Generated Cut Plan (Markdown) ---" + echo "$CUTPLAN_CONTENT" + echo "-------------------------------------" +else + echo "$CUTPLAN_CONTENT" > "$OUTPUT_FILE" + echo "Cut plan successfully saved to '$OUTPUT_FILE'." +fi \ No newline at end of file