fixed resolution passing to python file
This commit is contained in:
parent
1934faa7f4
commit
e254ceda4d
|
@ -40,7 +40,8 @@
|
|||
var exporter = new Print(undefined, doc, view);
|
||||
filename = inputfile.substring(inputfile.lastIndexOf("/")+1,inputfile.length-4);
|
||||
path2 = path+"Coordinatefiles/"+filename+".pdf";
|
||||
exporter.print(path2);
|
||||
exporter.print(path2);
|
||||
di.exportFile(path+"Coordinatefiles/"+filename+".dxf","DFX 2000");
|
||||
}
|
||||
di.destroy()
|
||||
}
|
||||
|
|
102
layers.txt
102
layers.txt
|
@ -1,79 +1,27 @@
|
|||
|
||||
0
|
||||
0.00
|
||||
00---0--FM-ARCEER
|
||||
00---0--FM-BRU2DEF
|
||||
00---0--FM-LEGPT
|
||||
00---0--FM-OBJECT
|
||||
00---0--FM-RUIMTEDEFN
|
||||
00---0--MEUBELS
|
||||
72AAV72D01__AH_A370_CHAIR
|
||||
72XYA52D01_AHREND_500_FRAME
|
||||
72XYA52D01_AHREND_500_LEG
|
||||
72XYA52D01_AHREND_500_TOP
|
||||
72XYZ32D01_AHREND_500_FRAME
|
||||
72XYZ32D01_AHREND_500_TOP
|
||||
72_AAX_A5_D2_ANY
|
||||
72_AAX_INSERT
|
||||
72_AAX_V7_D2_ANY
|
||||
72_AAX_Z3_D2_ANY
|
||||
A--L22_BINNENW_LM
|
||||
A--L89_losse inrichting
|
||||
A--M$1A_MAATVOER.-dimdot
|
||||
A--M$1A_MAATVOER.-wanden
|
||||
A--T$1B
|
||||
A--T$1B2
|
||||
AL43_VLOERLIJNEN
|
||||
AL82_MEUBELS
|
||||
APPARATUUR
|
||||
BALIE
|
||||
BB$4A---_STEMPEL
|
||||
BL$8F---_HID-WAND
|
||||
BL$8V---_VOUWLIJN
|
||||
BL------_LIFT
|
||||
BL------_VLOEREN
|
||||
BL210---_GEVEL
|
||||
BL2120--_MET_WAND
|
||||
BL2210--_BIN-WAND
|
||||
BL24----_TRAP
|
||||
BL281---_KOLOM
|
||||
BL282---_BET-WAND
|
||||
BL312---_BURAAM
|
||||
BL313---_BUDEUR
|
||||
BL3132--_BUSCHD
|
||||
BL3132A-_BUSCHD_ST
|
||||
BL322---_BIRAAM
|
||||
BL323---_BIDEUR
|
||||
BL3232A-_BISCHD_ST
|
||||
BL34----_BALUSTRADES
|
||||
BL66----_TRANSPORTINST
|
||||
BL70----_VASTE INRICHTING
|
||||
BL71----_PARKEERPLIJNEN
|
||||
BL71----_PARKEERPLLIJNEN
|
||||
BL75----_INRSCHOONMAAK
|
||||
BL79----_INRGEBOUW
|
||||
BL8211----_NIET-IN-CATALOGUS
|
||||
BL8211--_MEUBILAIR
|
||||
BL8211--_NIET-IN-CATALOGUS
|
||||
BL8211ND_OVERIG-MEUBILAIR
|
||||
BL94----_TERREINAFW
|
||||
BL99----_TERREIN
|
||||
BLAD-BALIE
|
||||
BM$1A---_MATEN-M
|
||||
D2_CH_GLIDES
|
||||
D2_CH_SEAT
|
||||
DEFAULT
|
||||
DEFPOINTS
|
||||
EB6441--_ATTRIB
|
||||
EL6441--_DATACOM
|
||||
HU-LP-1
|
||||
KASTJE_BALIE
|
||||
LOCATIE
|
||||
Level 1
|
||||
MDFSEGMENTEN
|
||||
PC
|
||||
TEGELS
|
||||
TELEF
|
||||
bemating historisch archief
|
||||
|
||||
BL82 INV
|
||||
A-ANNO-CATEGORY
|
||||
A-ANNO-EMPFIRST
|
||||
A-ANNO-EMPLAST
|
||||
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
|
||||
A-FURN-FILE
|
||||
A-FURN-FREE
|
||||
A-FURN-IDEN
|
||||
A-GLAZ
|
||||
A-TITLE
|
||||
A-WALL
|
||||
A-WALL-FULL
|
||||
A-WALL-MOVE
|
||||
Defpoints
|
||||
XRMNO
|
||||
####ZB-GB
|
||||
A-CEILING
|
||||
|
|
40
lines.py
40
lines.py
|
@ -2,38 +2,41 @@ import csv
|
|||
import sys
|
||||
import json
|
||||
import os
|
||||
import glob
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
sys.setrecursionlimit(20000)
|
||||
|
||||
|
||||
blobsize = 100
|
||||
buildingcount=1
|
||||
pixelList = []
|
||||
scannedPixels = []
|
||||
linesList = []
|
||||
allPixels = []
|
||||
gevondenpixels = []
|
||||
bloblist = []
|
||||
if len(sys.argv)<3:
|
||||
buildingcount = 1
|
||||
else:
|
||||
buildingcount = sys.argv[2]
|
||||
pngwidth=int(sys.argv[3])
|
||||
pngheigth=int(sys.argv[4])
|
||||
buildingcount = sys.argv[1]
|
||||
pngwidth=int(sys.argv[2])
|
||||
pngheigth=int(sys.argv[3])
|
||||
|
||||
def main(argv):
|
||||
def main():
|
||||
path="Coordinatefiles/*.csv"
|
||||
for fname in glob.glob(path):
|
||||
global pixelList, scannedPixels, linesList, allPixels,gevondenpixels,bloblist
|
||||
pixelList, scannedPixels, linesList, allPixels, gevondenpixels, bloblist = [[],[],[],[],[],[]]
|
||||
start(fname)
|
||||
|
||||
filename = sys.argv[1]
|
||||
def start(fname):
|
||||
|
||||
filename = fname.rsplit('/',1)[1]
|
||||
if filename.endswith('.csv'):
|
||||
filename=filename.replace('.csv','')
|
||||
if(not os.path.isdir("Coordinatefiles")):
|
||||
os.makedirs("Coordinatefiles")
|
||||
path = "Coordinatefiles/"+filename+".json"
|
||||
f= open(path,"w+")
|
||||
csvPath = "Coordinatefiles/"+filename+".csv"
|
||||
|
||||
with open(csvPath, newline='') as csvfile:
|
||||
with open(fname, newline='') as csvfile:
|
||||
file = csv.reader(csvfile, delimiter=' ', quotechar='|')
|
||||
|
||||
for row in file:
|
||||
|
@ -41,15 +44,18 @@ def main(argv):
|
|||
yCoordinate=row[0].split(',')[1]
|
||||
coordinate=[int(xCoordinate),int(yCoordinate)]
|
||||
allPixels.append(coordinate)
|
||||
print(len(allPixels))
|
||||
|
||||
for pixel in allPixels:
|
||||
blob = []
|
||||
if (not pixel in gevondenpixels):
|
||||
checkSurroundingPixels(pixel, blob)
|
||||
if(len(blob)>blobsize):
|
||||
bloblist.append(blob)
|
||||
bloblist.sort(key=len, reverse=True)
|
||||
print(filename)
|
||||
|
||||
for i in range(0,max(1,int(buildingcount))):
|
||||
for i in range(0,min(int(buildingcount),int(len(bloblist)))):
|
||||
for pixel in bloblist[i]:
|
||||
pixelList.append(pixel)
|
||||
|
||||
|
@ -121,7 +127,7 @@ def main(argv):
|
|||
f.write('\":')
|
||||
f.write(json.dumps(floor))
|
||||
f.write("}")
|
||||
draw(pixelList,linesList,argv)
|
||||
draw(pixelList,linesList,filename)
|
||||
|
||||
|
||||
def checkSurroundingPixels(pixel, blob):
|
||||
|
@ -210,8 +216,8 @@ def checkAlreadyScanned(pixel):
|
|||
return True
|
||||
return False
|
||||
|
||||
def draw(pixelList, linesList,argv):
|
||||
canvas = (int(sys.argv[3]),int(sys.argv[4]))
|
||||
def draw(pixelList, linesList,file):
|
||||
canvas = (int(sys.argv[2]),int(sys.argv[3]))
|
||||
scale = 1
|
||||
thumb = canvas[0] / scale, canvas[1] / scale
|
||||
im = Image.new('RGBA', canvas, (255, 255, 255, 255))
|
||||
|
@ -221,8 +227,8 @@ def draw(pixelList, linesList,argv):
|
|||
for pixel in pixelList:
|
||||
draw.point([pixel[0],pixel[1]],fill="black")
|
||||
im.thumbnail(thumb)
|
||||
pngfile , sep, tail = argv[1].partition('.')
|
||||
pngfile , sep, tail = file.partition('.')
|
||||
im.save("Coordinatefiles/"+pngfile+"outline"+'.png')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv)
|
||||
main()
|
31
start
31
start
|
@ -38,6 +38,7 @@ mainConversion (){
|
|||
-clone 0 \
|
||||
-fill "#000000" \
|
||||
-colorize 100 \
|
||||
-colorize 100 \
|
||||
\) \
|
||||
\( \
|
||||
-clone 0,1 \
|
||||
|
@ -107,9 +108,7 @@ getCoordinates (){
|
|||
|
||||
cat "Coordinatefiles/test4.txt" | grep -vE '#' | sed 's/://g' > "Coordinatefiles/$cleanfile.csv"
|
||||
|
||||
width=$(identify -format '%w' "Coordinatefiles/finaledges.png")
|
||||
height=$(identify -format '%h' "Coordinatefiles/finaledges.png")
|
||||
python3 lines.py "$cleanfile.csv" "$buildingcount" "$width" "$height"
|
||||
|
||||
}
|
||||
|
||||
progressBar () {
|
||||
|
@ -148,31 +147,27 @@ createHelperFile(){
|
|||
echo "-Threshold $THRESHOLD" >> $file
|
||||
echo "-buildingcount $buildingcount" >> $file
|
||||
layer="./layers.txt"
|
||||
echo "\n--Active layers list for wall--\n" >> $file
|
||||
echo "to be filled with layers that will only show the wall" >> $file
|
||||
echo "\n--Active layer list--\n" >> $file
|
||||
awk '!a[$0]++' "layers.txt" >>$file
|
||||
}
|
||||
|
||||
createDirectories(){
|
||||
rmdir "Coordinatefiles/combined.json"
|
||||
rmdir "Coordinatefiles/minified.json"
|
||||
rm -f "Coordinatefiles/minified.json"
|
||||
if [[ ! -e "$DWGfiles" ]]; then
|
||||
mkdir DWGfiles
|
||||
mkdir -p DWGfiles
|
||||
fi
|
||||
if [[ ! -e "$PNG" ]]; then
|
||||
mkdir PNG
|
||||
mkdir -p PNG
|
||||
fi
|
||||
if [[ ! -e "$Helperfiles" ]]; then
|
||||
mkdir Helperfiles
|
||||
mkdir -p Helperfiles
|
||||
fi
|
||||
if [[ ! -e "$PRIMEPNG" ]]; then
|
||||
mkdir PRIMEPNG
|
||||
mkdir -p PRIMEPNG
|
||||
fi
|
||||
if [[ ! -e "Coordinatefiles" ]]; then
|
||||
mkdir Coordinatefiles
|
||||
mkdir -p Coordinatefiles
|
||||
fi
|
||||
touch "Coordinatefiles/combined.json"
|
||||
}
|
||||
|
||||
removeCapitalLetters(){
|
||||
|
@ -196,7 +191,7 @@ 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..."
|
||||
|
||||
for f in $FILES*.dwg
|
||||
for f in $FILES*.dwg
|
||||
do
|
||||
pdffile=${f##*/}
|
||||
cleanfile=${pdffile%.*}
|
||||
|
@ -211,6 +206,12 @@ fi
|
|||
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"
|
||||
|
@ -227,7 +228,7 @@ for c in $Coordinatefiles*.json
|
|||
jq -s add "${array[@]}" > "Coordinatefiles/final.json"
|
||||
jq -c . < "Coordinatefiles/final.json" > "Coordinatefiles/minified.json"
|
||||
|
||||
rm "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"
|
||||
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.
|
||||
|
|
Loading…
Reference in New Issue