diff options
author | Michael Schwarz <michi.schwarz@gmail.com> | 2014-11-26 16:24:08 +0100 |
---|---|---|
committer | Michael Schwarz <michi.schwarz@gmail.com> | 2014-11-27 18:18:27 +0100 |
commit | 16d3e4a963d7fd299042ba27778744e0bd7da037 (patch) | |
tree | 9148c097353b3241c6895c6c74fe3f583ca85c6e /dxf_export/main.sh | |
download | pogojig-16d3e4a963d7fd299042ba27778744e0bd7da037.tar.gz pogojig-16d3e4a963d7fd299042ba27778744e0bd7da037.tar.bz2 pogojig-16d3e4a963d7fd299042ba27778744e0bd7da037.zip |
First version of the template project.
Diffstat (limited to 'dxf_export/main.sh')
-rwxr-xr-x | dxf_export/main.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/dxf_export/main.sh b/dxf_export/main.sh new file mode 100755 index 0000000..ef888b0 --- /dev/null +++ b/dxf_export/main.sh @@ -0,0 +1,36 @@ +#! /usr/bin/env bash + +in_file=$1 +out_file=$2 + +# If environment variable DXF_EXPORT_DEBUG is set, the temporary file that is modified using Inkscape is saved in the same directory as the source file and not removed. +if [ "$DXF_EXPORT_DEBUG" ]; then + temp_file="$(dirname "$in_file")/$(basename "$in_file" '.svg')~temp.svg" +else + temp_dir=$(mktemp -d) + temp_file="$temp_dir/temp.svg" +fi + +script_path=$(dirname "$BASH_SOURCE") + +cp "$in_file" "$temp_file" + +# Run a few commands using Inkscape on the SVG file to get in into a shape that makes a successful conversion to DXF more likely. +"$INKSCAPE" \ + --verb UnlockAllInAllLayers \ + --verb EditSelectAllInAllLayers \ + --verb ObjectToPath \ + --verb EditSelectAllInAllLayers \ + --verb SelectionUnGroup \ + --verb EditSelectAllInAllLayers \ + --verb StrokeToPath \ + --verb FileSave \ + --verb FileClose \ + "$temp_file" + +# Convert the SVG to a DXF file. +python2 "$script_path/better_dxf_outlines.py" "$temp_file" > "$out_file" + +if ! [ "$DXF_EXPORT_DEBUG" ]; then + rm -rf "$temp_dir" +fi |