saw cut list gen

This commit is contained in:
babayaga 2025-07-04 14:33:26 +02:00
parent e8e42e27b6
commit d3c45bff2f
2 changed files with 79 additions and 0 deletions

27
cad/drawers/tools/cp.md Normal file
View File

@ -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*

View File

@ -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 <source.scad> [output.md]
# If output file is not provided, prints to console.
# --- Input Validation ---
if [ -z "$1" ]; then
echo "Usage: $0 <source.scad> [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