Skip to content

Commit 8c0511d

Browse files
committed
fix #4 txt coordinate list to dxf
1 parent 9366627 commit 8c0511d

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

awk/txt2dxf.awk

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/gawk -f
2+
#
3+
# create minimal dxf file from space delimited coordinate list
4+
# point positions and point_ids as text are sent to dxf
5+
# input coordinate format:
6+
# point_id easting northing elevation code/layer
7+
# elevations and codes are optional
8+
# (C) Zoltan Siki siki.zoltan@emk.bme.hu
9+
# usage:
10+
# gawk -f txt2dxf.awk coodinate_list > dxf_file
11+
12+
BEGIN { FS="[ ]";
13+
# some constants in dxf units
14+
dx = 0.1; # easting offset of point id text
15+
dy = -0.25; # northin offset of point id text
16+
th = 0.5; # text height of point id text
17+
# minimal DXF header
18+
print " 0";
19+
print "SECTION";
20+
print " 2";
21+
print "ENTITIES"
22+
}
23+
24+
{ # for each input line
25+
if (NF < 4 || $4 == "") {
26+
elev = 0.0; # default elevation
27+
} else {
28+
elev = $4;
29+
}
30+
if (NF < 5 || $5 == "") {
31+
layer = "POINTS"; # default layer
32+
} else {
33+
layer = $5;
34+
}
35+
# point id text
36+
printf " 0\nTEXT\n 8\n%s\n 10\n%f\n 20\n%f\n 30\n%f\n", layer, $2+dx, $3+dyi, elev;
37+
printf " 40\n%f\n 50\n0.0\n 1\n%s\n", th, $1;
38+
# point entity
39+
printf " 0\nPOINT\n 8\n%s\n 10\n%f\n 20\n%f\n 30\n%f\n", layer, $2, $3, elev;
40+
}
41+
42+
END {
43+
# footer for DXF
44+
print " 0\nENDSEC\n 0\nEOF"
45+
}

0 commit comments

Comments
 (0)