Added pictures

This commit is contained in:
cpu
2025-11-28 16:59:55 +01:00
parent 511c990f3c
commit 18793a8a27
16 changed files with 1343 additions and 265 deletions

View File

@@ -14,48 +14,53 @@ THICKNESS_MM="0.1"
# DPI based on the 3D printer resolution (e.g. 1494 for Anycubic Photon Mono 4)
EXPORT_DPI=1494
# ---------------------
# 1. Check Input
if [ -z "$1" ]; then
echo "Error: No input file provided."
echo "Usage: ./svg2stl.sh <input.svg>"
# Check for at least one input file
if [ "$#" -lt 1 ]; then
echo "Error: No input files provided."
echo "Usage: ./svg2stl.sh <file1.svg> [file2.svg ...]"
exit 1
fi
# 2. Setup Absolute Paths
INPUT_FILE="$(readlink -f "$1")"
WORK_DIR="$(dirname "$INPUT_FILE")"
BASENAME="$(basename "$INPUT_FILE" .svg)"
TEMP_SVG="$WORK_DIR/${BASENAME}_temp_processed.svg"
OUTPUT_STL="$WORK_DIR/$BASENAME.stl"
# Loop over all input files
for INPUT in "$@"; do
INPUT_FILE="$(readlink -f "$INPUT")"
# 3. Inkscape Processing
# Note: We do NOT resize here. We export high-res geometry and resize in Blender.
ACTIONS="select-by-element:text;delete;select-all;object-stroke-to-path;path-union;export-plain-svg;export-filename:$TEMP_SVG;export-do"
INK_ARGS="--export-dpi=$EXPORT_DPI --actions=$ACTIONS"
echo "Processing: $INPUT_FILE"
echo "------------------------------------------------"
echo "Step 1: Inkscape Processing"
echo "Input: $INPUT_FILE"
echo "------------------------------------------------"
# Setup Absolute Paths
WORK_DIR="$(dirname "$INPUT_FILE")"
BASENAME="$(basename "$INPUT_FILE" .svg)"
TEMP_SVG="$WORK_DIR/${BASENAME}_temp_processed.svg"
OUTPUT_STL="$WORK_DIR/$BASENAME.stl"
inkscape "$INPUT_FILE" $INK_ARGS
# Inkscape Processing
# Note: We do NOT resize here. We export high-res geometry and resize in Blender.
ACTIONS="select-by-element:text;delete;select-all;object-stroke-to-path;path-union;export-plain-svg;export-filename:$TEMP_SVG;export-do"
INK_ARGS="--export-dpi=$EXPORT_DPI --actions=$ACTIONS"
if [ ! -f "$TEMP_SVG" ]; then
echo "ERROR: Inkscape failed to create the temp file."
exit 1
fi
echo "------------------------------------------------"
echo "Step 1: Inkscape Processing"
echo "Input: $INPUT_FILE"
echo "------------------------------------------------"
echo "------------------------------------------------"
echo "Step 2: Blender Processing"
echo "Target Width: ${TARGET_WIDTH_MM} mm"
echo "Target Thickness: ${THICKNESS_MM} mm"
echo "------------------------------------------------"
inkscape "$INPUT_FILE" $INK_ARGS
# Pass Width and Thickness to Python
blender --background --python pcb_to_stl.py -- "$TEMP_SVG" "$OUTPUT_STL" "$THICKNESS_MM" "$TARGET_WIDTH_MM"
if [ ! -f "$TEMP_SVG" ]; then
echo "ERROR: Inkscape failed to create the temp file."
exit 1
fi
# 4. Cleanup
rm "$TEMP_SVG"
echo "Done! Saved to $OUTPUT_STL"
echo "------------------------------------------------"
echo "Step 2: Blender Processing"
echo "Target Width: ${TARGET_WIDTH_MM} mm"
echo "Target Thickness: ${THICKNESS_MM} mm"
echo "------------------------------------------------"
# Pass Width and Thickness to Python
blender --background --python pcb_to_stl.py -- "$TEMP_SVG" "$OUTPUT_STL" "$THICKNESS_MM" "$TARGET_WIDTH_MM"
# Cleanup
rm "$TEMP_SVG"
echo "Done! Saved to $OUTPUT_STL"
# ---------------------
done