#!/usr/bin/env bash set -euo pipefail IMGSIZE="1280,960" REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)" if ! command -v openscad &>/dev/null; then echo "Error: openscad not found in PATH" >&2 exit 1 fi count=0 while IFS= read -r -d '' scad_file; do dir="$(dirname "$scad_file")" output="${dir}/preview.png" echo "Rendering ${scad_file} -> ${output}" openscad --render --autocenter --viewall --imgsize "$IMGSIZE" -o "$output" "$scad_file" count=$((count + 1)) done < <(find "$REPO_DIR" -name '*.scad' -not -path "$REPO_DIR/lib/*" -print0) echo "Generated ${count} preview(s)."