-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
226d774
commit 732f672
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/gawk -f | ||
# | ||
# create minimal dxf file from space delimited coordinate list | ||
# point positions and point_ids as text are sent to dxf | ||
# input coordinate format: | ||
# point_id easting northing elevation code/layer | ||
# elevations and codes are optional | ||
# (C) Zoltan Siki [email protected] | ||
# usage: | ||
# 1) for space | ||
# gawk -f txt2dxf.awk coodinate_list > dxf_file | ||
# 2) for comma | ||
# gawk -F, -f txt2dxf.awk coodinate_list > dxf_file | ||
|
||
BEGIN { | ||
# some constants in dxf units | ||
dx = 0.1; # easting offset of point id text | ||
dy = -0.25; # northin offset of point id text | ||
th = 0.5; # text height of point id text | ||
# minimal DXF header | ||
print " 0"; | ||
print "SECTION"; | ||
print " 2"; | ||
print "ENTITIES" | ||
} | ||
|
||
{ # for each input line | ||
if (NF < 4 || $4 == "") { | ||
elev = 0.0; # default elevation | ||
} else { | ||
elev = $4; | ||
} | ||
if (NF < 5 || $5 == "") { | ||
layer = "POINTS"; # default layer | ||
} else { | ||
layer = $5; | ||
} | ||
# point id text | ||
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; | ||
printf " 40\n%f\n 50\n0.0\n 1\n%s\n", th, $1; | ||
# point entity | ||
printf " 0\nPOINT\n 8\n%s\n 10\n%f\n 20\n%f\n 30\n%f\n", layer, $2, $3, elev; | ||
} | ||
|
||
END { | ||
# footer for DXF | ||
print " 0\nENDSEC\n 0\nEOF" | ||
} |