Added pictures
This commit is contained in:
75
svg2stl.sh
75
svg2stl.sh
@@ -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
|
||||
Reference in New Issue
Block a user