Last active
March 4, 2018 10:23
-
-
Save joakimsk/a72d456566285ac96d845de13065687a to your computer and use it in GitHub Desktop.
Convert DWG to DXF using Teigha in batch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To execute in batch mode | |
# find . -iname "*.dwg" -print0 | xargs -0 -I {} ./sh-dwgtodxf.sh -i "{}" | |
TEIGHA="/Applications/TeighaFileConverter.app/Contents/MacOS/TeighaFileConverter" | |
OUTVER="ACAD2004" | |
OUTFORMAT="DXF" | |
RECURSIVE="0" | |
AUDIT="1" | |
INPUTFILTER="*.DWG" | |
while getopts ":i:" opt; do | |
case $opt in | |
i) | |
echo "-i was triggered, Parameter: $OPTARG" >&2 | |
FILENAME=${OPTARG##*/} | |
PATHNAME=`dirname "$OPTARG"` | |
FILE=${FILENAME%.*} | |
echo "Working on $PATHNAME/$FILENAME" | |
mkdir "temp" | |
cp "$OPTARG" "temp/$FILENAME" | |
/Applications/TeighaFileConverter.app/Contents/MacOS/TeighaFileConverter temp/ temp/ $OUTVER $OUTFORMAT $RECURSIVE $AUDIT $INPUTFILTER | |
cp "temp/$FILE.dxf" "$PATHNAME/" | |
rm -rf "temp/" | |
;; | |
\?) | |
echo "Invalid option: -$OPTARG" >&2 | |
exit 1 | |
;; | |
:) | |
echo "Option -$OPTARG requires an argument." >&2 | |
exit 1 | |
;; | |
esac | |
done | |
# Command Line Format for Teigha is: | |
# Quoted Input Folder | |
# Quoted Output Folder | |
# Output_version | |
# {"ACAD9","ACAD10","ACAD12", | |
# "ACAD13","ACAD14", | |
# "ACAD2000","ACAD2004", | |
# "ACAD2007","ACAD2010", | |
# "ACAD2013","ACAD2018"} | |
# Output File type | |
# {"DWG","DXF","DXB"} | |
# Recurse Input Folder | |
# {"0","1"} | |
# Audit each file | |
# {"0","1"} | |
# [optional] Input files filter | |
# (default: "*.DWG;*.DXF") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment