poly-mech/cad/drawers/tools/generate_cutlist.sh
2025-07-04 14:25:51 +02:00

34 lines
1.0 KiB
Bash

#!/bin/bash
# --- generate_cutlist.sh ---
# Generates a markdown cut plan by calling an external Python script.
# This bypasses a bug in some OpenSCAD versions that prevents the echo
# module from functioning correctly.
#
# Usage: ./generate_cutlist.sh [output.md]
# All parameters are taken from the defaults in the python script.
# For custom dimensions, edit calculate_cuts.py or call it directly.
OUTPUT_FILE="$1"
# Run the python script to generate the markdown content.
# The script can be modified to change box parameters.
CUTLIST_CONTENT=$(python calculate_cuts.py)
# Check the exit status of the python script.
if [ $? -ne 0 ]; then
echo ""
echo "Error: Python script 'calculate_cuts.py' failed."
exit 1
fi
# --- Output the result ---
if [ -z "$OUTPUT_FILE" ]; then
echo ""
echo "--- Generated Cut Plan (Markdown) ---"
echo "$CUTLIST_CONTENT"
echo "-------------------------------------"
else
echo "$CUTLIST_CONTENT" > "$OUTPUT_FILE"
echo "Cut plan successfully saved to '$OUTPUT_FILE'."
fi