forked from bmsleight/lasercut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert-2d.sh
37 lines (28 loc) · 883 Bytes
/
convert-2d.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Defines where OpenSCAD is installed
openscad_bin() {
if [ -n "$OPENSCAD_BIN" ]
then
$OPENSCAD_BIN $1
elif [[ "$OSTYPE" == "darwin"* ]]
then
/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD $1
else
openscad $1
fi
}
# Creates a 2d plan of your 3D model
TMPCSG=/tmp/$(basename $1).csg
TMPSCAD=/tmp/$(basename $1).scad
openscad_bin "$1 -D generate=1 -o $TMPCSG" 2>&1 >/dev/null | sed -e 's/ECHO: \"\[LC\] //' -e 's/"$//' -e '$a\;' -e '/WARNING/d' >$TMPSCAD
sed -i.tmp '1 i\
// May need to adjust location of <lasercut.scad> \
use <lasercut.scad> ;\
\$fn=60;\
projection(cut = false)\
' $TMPSCAD
# Exports in others formats (could be very long)
#openscad_bin "./2d_$1 -o ./2d_$1.csg"
#openscad_bin "./2d_$1 -o ./2d_$1.dxf"
#openscad_bin "./2d_$1 -o ./2d_$1.svg"
#openscad_bin "./$1 -o ./3d_$1.stl"
mv $TMPSCAD $(dirname $1)/$(basename $1)_2d.scad