even more modularity
This commit is contained in:
parent
e254ceda4d
commit
030a4224e8
|
@ -1,20 +1,17 @@
|
|||
--Command to run--
|
||||
|
||||
./start -x -66000 -y 4000 -w 117 -h 34.5 -s 1000 -p 2400 -t 0.08
|
||||
./start -x -66000 -y 4000 -w 117 -h 34.5 -s 1000 -p 600 -t 0.01 -b 1
|
||||
|
||||
--Variables--
|
||||
--Variables--
|
||||
|
||||
-xoffset: -66000
|
||||
-yoffset: 4000
|
||||
-width: 117
|
||||
-height: 34.5
|
||||
-scale: 1000
|
||||
-PPI: 2400
|
||||
-Threshold 0.08
|
||||
|
||||
--Active layers list for wall--
|
||||
|
||||
to be filled with layers that will only show the wall
|
||||
-PPI: 600
|
||||
-Threshold 0.01
|
||||
-buildingcount 1
|
||||
|
||||
--Active layer list--
|
||||
|
||||
|
@ -23,13 +20,13 @@ to be filled with layers that will only show the wall
|
|||
A-ANNO-CATEGORY
|
||||
A-ANNO-EMPFIRST
|
||||
A-ANNO-EMPLAST
|
||||
####ZB-GB
|
||||
A-ANNO-ORGANIZATION
|
||||
A-COLS
|
||||
A-DOOR
|
||||
A-EQPM
|
||||
A-EQPM-FIXD
|
||||
A-FLOR-EVTR
|
||||
A-FLOR-HRAL
|
||||
A-FLOR-LEVL
|
||||
A-FLOR-OTLN
|
||||
A-FLOR-STRS
|
||||
|
@ -43,5 +40,5 @@ A-WALL-FULL
|
|||
A-WALL-MOVE
|
||||
Defpoints
|
||||
XRMNO
|
||||
I-FURN-EQPM
|
||||
A-—L-1
|
||||
####ZB-GB
|
||||
A-CEILING
|
||||
|
|
4
lines.py
4
lines.py
|
@ -7,7 +7,7 @@ from PIL import Image, ImageDraw
|
|||
|
||||
sys.setrecursionlimit(20000)
|
||||
|
||||
|
||||
#python3 lines.py <number of buildings> <width> <height>
|
||||
blobsize = 100
|
||||
pixelList = []
|
||||
scannedPixels = []
|
||||
|
@ -44,7 +44,6 @@ def start(fname):
|
|||
yCoordinate=row[0].split(',')[1]
|
||||
coordinate=[int(xCoordinate),int(yCoordinate)]
|
||||
allPixels.append(coordinate)
|
||||
print(len(allPixels))
|
||||
|
||||
for pixel in allPixels:
|
||||
blob = []
|
||||
|
@ -53,7 +52,6 @@ def start(fname):
|
|||
if(len(blob)>blobsize):
|
||||
bloblist.append(blob)
|
||||
bloblist.sort(key=len, reverse=True)
|
||||
print(filename)
|
||||
|
||||
for i in range(0,min(int(buildingcount),int(len(bloblist)))):
|
||||
for pixel in bloblist[i]:
|
||||
|
|
144
start
144
start
|
@ -1,4 +1,5 @@
|
|||
#!/bin/sh
|
||||
clear
|
||||
Outerwallsflag="false"
|
||||
PPI=600
|
||||
THRESHOLD=0.01
|
||||
|
@ -11,25 +12,11 @@ taskCount=(*.dwg)
|
|||
taskCount=${#taskCount[@]}
|
||||
taskDone=0
|
||||
progressBarWidth=20
|
||||
allparam=( "$@" )
|
||||
|
||||
while getopts "x:y:w:h:s:p:t:b: o" option
|
||||
do
|
||||
case "${option}"
|
||||
in
|
||||
x) XOFF=$OPTARG;;
|
||||
y) YOFF=$OPTARG;;
|
||||
w) WIDTH=$OPTARG;;
|
||||
h) HEIGHT=$OPTARG;;
|
||||
s) SCALE=$OPTARG;;
|
||||
t) THRESHOLD=$OPTARG;;
|
||||
p) PPI=$OPTARG;;
|
||||
o) Outerwallsflag="true";;
|
||||
b) buildingcount=$OPTARG;;
|
||||
esac
|
||||
done
|
||||
|
||||
mainConversion (){
|
||||
|
||||
|
||||
convert -density $2 \
|
||||
"Helperfiles/$1.pdf" \
|
||||
-alpha off \
|
||||
|
@ -107,8 +94,6 @@ getCoordinates (){
|
|||
awk '{print $1}' "Coordinatefiles/test3.txt" > "Coordinatefiles/test4.txt"
|
||||
|
||||
cat "Coordinatefiles/test4.txt" | grep -vE '#' | sed 's/://g' > "Coordinatefiles/$cleanfile.csv"
|
||||
|
||||
|
||||
}
|
||||
|
||||
progressBar () {
|
||||
|
@ -133,11 +118,11 @@ progressBar () {
|
|||
}
|
||||
|
||||
createHelperFile(){
|
||||
file="Helperfiles/Helperfile.txt"
|
||||
file="Helperfile.txt"
|
||||
touch $file
|
||||
echo "--Command to run--\n" > $file
|
||||
echo "./start -x $XOFF -y $YOFF -w $WIDTH -h $HEIGHT -s $SCALE -p $PPI -t $THRESHOLD -b $buildingcount" >> $file
|
||||
echo "\n --Variables-- \n" >> $file
|
||||
echo "\n--Variables-- \n" >> $file
|
||||
echo "-xoffset: $XOFF" >> $file
|
||||
echo "-yoffset: $YOFF" >> $file
|
||||
echo "-width: $WIDTH" >> $file
|
||||
|
@ -184,54 +169,109 @@ removeCapitalLetters(){
|
|||
done
|
||||
}
|
||||
|
||||
readHelperfile(){
|
||||
command=$(grep "./start" "./Helperfile.txt")
|
||||
commandarray=($command)
|
||||
if [[ -z ${XOFF+x} ]]; then XOFF=${commandarray[2]}; fi
|
||||
if [[ -z ${YOFF+x} ]]; then YOFF=${commandarray[4]}; fi
|
||||
if [[ -z ${WIDTH+x} ]]; then WIDTH=${commandarray[6]}; fi
|
||||
if [[ -z ${HEIGHT+x} ]]; then HEIGHT=${commandarray[8]}; fi
|
||||
if [[ -z ${SCALE+x} ]]; then SCALE=${commandarray[10]}; fi
|
||||
if [[ -z ${PPI+x} ]]; then PPI=${commandarray[12]}; fi
|
||||
if [[ -z ${THRESHOLD+x} ]]; then THRESHOLD=${commandarray[14]}; fi
|
||||
if [[ -z ${buildingcount+x} ]]; then buildingcount=${commandarray[16]}; fi
|
||||
}
|
||||
|
||||
if [[ ${#allparam[@]} -le 9 ]]; then
|
||||
if [[ ! -e "Helperfile.txt" ]]; then
|
||||
echo "No helperfile found in the current directory. Please fill in all parameters."
|
||||
exit -1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
while getopts "x:y:w:h:s:p:t:b: o" option
|
||||
do
|
||||
case "${option}"
|
||||
in
|
||||
x) XOFF=$OPTARG;;
|
||||
y) YOFF=$OPTARG;;
|
||||
w) WIDTH=$OPTARG;;
|
||||
h) HEIGHT=$OPTARG;;
|
||||
s) SCALE=$OPTARG;;
|
||||
t) THRESHOLD=$OPTARG;;
|
||||
p) PPI=$OPTARG;;
|
||||
o) Outerwallsflag="true";;
|
||||
b) buildingcount=$OPTARG;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! -z ${XOFF+x} ]; then XOFF=$XOFF; fi
|
||||
if [ ! -z ${YOFF+x} ]; then YOFF=$YOFF; fi
|
||||
if [ ! -z ${WIDTH+x} ]; then WIDTH=$WIDTH; fi
|
||||
if [ ! -z ${HEIGHT+x} ]; then HEIGHT=$HEIGHT; fi
|
||||
if [ ! -z ${SCALE+x} ]; then SCALE=$SCALE; fi
|
||||
if [ ! -z ${THRESHOLD+x} ]; then THRESHOLD=$THRESHOLD; fi
|
||||
if [ ! -z ${PPI+x} ]; then PPI=$PPI; fi
|
||||
if [ ! -z ${Outerwallsflag+x} ]; then Outerwallsflag=$Outerwallsflag; fi
|
||||
if [ ! -z ${buildingcount+x} ]; then buildingcount=$buildingcount; fi
|
||||
|
||||
|
||||
|
||||
if [[ -e "Helperfile.txt" ]];then
|
||||
readHelperfile
|
||||
fi
|
||||
createDirectories
|
||||
createHelperFile
|
||||
removeCapitalLetters
|
||||
|
||||
echo "\n\nStarting script with -x $XOFF -y $YOFF -w $WIDTH -h $HEIGHT -s $SCALE -p $PPI -t $THRESHOLD -b $buildingcount -o $Outerwallsflag \nMore details can be found in the Helperfile inside the Helperfiles directory."
|
||||
echo "\n...please be patient..."
|
||||
echo "\n\nStarting script with\n\
|
||||
|| -x $XOFF || -y $YOFF || -w $WIDTH || -h $HEIGHT || -s $SCALE || \n\
|
||||
|| -p $PPI || -t $THRESHOLD || \n\
|
||||
||-b $buildingcount || -o $Outerwallsflag ||\
|
||||
\nMore details can be found in the Helperfile.\
|
||||
\n...please be patient..."
|
||||
|
||||
for f in $FILES*.dwg
|
||||
do
|
||||
pdffile=${f##*/}
|
||||
cleanfile=${pdffile%.*}
|
||||
text=$(echo "$cleanfile done")
|
||||
"$binary" -no-gui -no-dock-icon -allow-multiple-instances -autostart "javascript.js" "-f" "$f" "-x" "$XOFF" "-y" "$YOFF" "-w" "$WIDTH" "-h" "$HEIGHT" "-s" "$SCALE" "-o" "$Outerwallsflag" "-r" 2>$1 | grep "MESSAGE:"
|
||||
mainConversion $cleanfile $PPI $THRESHOLD
|
||||
do
|
||||
pdffile=${f##*/}
|
||||
cleanfile=${pdffile%.*}
|
||||
text=$(echo "$cleanfile done")
|
||||
"$binary" -no-gui -no-dock-icon -allow-multiple-instances -autostart "javascript.js" "-f" "$f" "-x" "$XOFF" "-y" "$YOFF" "-w" "$WIDTH" "-h" "$HEIGHT" "-s" "$SCALE" "-o" "$Outerwallsflag" "-r" 2>"-x" | grep "MESSAGE:"
|
||||
mainConversion $cleanfile $PPI $THRESHOLD
|
||||
|
||||
if [ "$Outerwallsflag" == "true" ];then
|
||||
getCoordinates $PPI $cleanfile
|
||||
fi
|
||||
(( tasksDone += 1 ))
|
||||
progressBar $taskCount $taskDone $text
|
||||
if [ "$Outerwallsflag" == "true" ];then
|
||||
getCoordinates $PPI $cleanfile
|
||||
pngs="$FILES""PNG/"*.png
|
||||
arr=($pngs)
|
||||
width=$(identify -format '%w' "${arr[0]}")
|
||||
height=$(identify -format '%h' "${arr[0]}")
|
||||
python3 lines.py "$buildingcount" "$width" "$height"
|
||||
Coordinatefiles=$PWD/Coordinatefiles/
|
||||
array=()
|
||||
for c in $Coordinatefiles*.json
|
||||
do
|
||||
array+=("$c")
|
||||
done
|
||||
|
||||
jq -s add "${array[@]}" > "Coordinatefiles/final.json"
|
||||
jq -c . < "Coordinatefiles/final.json" > "Coordinatefiles/minified.json"
|
||||
fi
|
||||
|
||||
(( tasksDone += 1 ))
|
||||
progressBar $taskCount $taskDone $text
|
||||
done
|
||||
|
||||
pngs="$FILES""PNG/"*.png
|
||||
arr=($pngs)
|
||||
width=$(identify -format '%w' "${arr[0]}")
|
||||
height=$(identify -format '%h' "${arr[0]}")
|
||||
python3 lines.py "$buildingcount" "$width" "$height"
|
||||
|
||||
for f in $FILES*.dwg
|
||||
do
|
||||
mv "$f" "DWGfiles"
|
||||
done
|
||||
|
||||
|
||||
Coordinatefiles=$PWD/Coordinatefiles/
|
||||
array=()
|
||||
for c in $Coordinatefiles*.json
|
||||
do
|
||||
array+=("$c")
|
||||
done
|
||||
|
||||
jq -s add "${array[@]}" > "Coordinatefiles/final.json"
|
||||
jq -c . < "Coordinatefiles/final.json" > "Coordinatefiles/minified.json"
|
||||
mv "$f" "DWGfiles"
|
||||
done
|
||||
|
||||
rm -f "Coordinatefiles/finaledges.png" "Coordinatefiles/final.json" "Coordinatefiles/filled.png" "Coordinatefiles/finallines.png" "Coordinatefiles/auto-level.png" "Coordinatefiles/final.png" "Coordinatefiles/5.png" "Coordinatefiles/test1.txt" "Coordinatefiles/test2.txt" "Coordinatefiles/test3.txt" "Coordinatefiles/test4.txt" "Coordinatefiles/1.png" "Coordinatefiles/2.png" "Coordinatefiles/4.png"
|
||||
|
||||
echo "\n...should be all done..."
|
||||
#Just to remove the annoying debug log that QCAD automatically makes. This keeps the terminal screen clean as well.
|
||||
log="./$1"
|
||||
log="./-x"
|
||||
[ -e "$log" ] && rm $log
|
||||
|
||||
|
|
Loading…
Reference in New Issue