Skip to content

Instantly share code, notes, and snippets.

@hroncok hroncok/svgto3d
Last active May 20, 2019

Embed
What would you like to do?
Get a list of svg files and convert them to prepared scad designs. You'l than have to modify only the size.
#!/usr/bin/env bash
# Public domain
if [ $# -lt 1 ]; then
echo "Give me some file(s), dude!" 1>&2
exit 1
fi
for svg in $@; do
shortname="$(basename "$svg")"
extension="${svg##*.}"
filename="${svg%.*}"
if [ "x${extension,,}" != "xsvg" ]; then
echo "$svg has no .svg extension, I won't use it." 1>&2
continue
fi
inkscape -E "${filename}".{eps,svg} || exit 1
pstoedit -dt -f dxf:-polyaslines "${filename}".{eps,dxf} || exit 1
if [ -f "${filename}.scad" ]; then
echo "Not going to overwrite ${filename}.scad, sorry." 1>&2
continue
fi
echo "scale(1) linear_extrude(height=1) import(\"${shortname%.*}.dxf\");" > "${filename}.scad"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.