1、导线平差结果
全站仪导线平差软件导出成果点格式为:点号 X Y h 标识码 序列号 时间,具体如下图,每列的空格间距还不一致。
2、EPS导入点格式
EPS中要求点按照:N,Y,X,h 格式导入,需要把1中的格式转位格式。平常是使用Excel表进行更改,操作较为麻烦。
3、使用EPScript编写程序
Sub OnClick()
'添加代码
dim fso,MyFile,NewFile,FileName,GetLine
dim dat
const ForReading=1
Set fso=createobject("scripting.FileSystemObject")
FileName=ssprocess.selectfilename(1,"",0,"DatFile(*.dat)|*.dat|TextFile(*.txt)|*.txt||")
set MyFile=fso.OpenTextFile(FileName,ForReading)
''''''逐行读取''''''''
dim s()
i=1
redim s(i) '定义数组大小
''使用until当条件为ture之前一致执行
' .AtEndOfSrream属性:如果文件指针位于 TextStream 文件末,则返回 True;
' 否则返回 False。仅应用于以只读方式打开的 TextStream 文件,否则会出现错误。
do until MyFile.atEndOfStream
s(i)=MyFile.readLine() '读取数据
i=i+1
redim preserve s(i) '重新定义数组大小
loop
redim preserve s(i-1) '将数组最后一位删除
lng=ubound(s)-lbound(s) '计算数组有多少个元素
MyFile.close '关闭MyFile文件夹
''''''文件名后缀替换为.txt''''''
set f=fso.getfile(FileName) '返回与指定路径中某文件相应的 File 对
p=f.Path
dat=right(p,4)
if dat= ".DAT" then
pp=replace(p,dat,".txt")
elseif dat= ".dat" then
pp=replace(p,dat,".txt")
else
pp=p
end if
Set NewFile=fso.createTextFile(pp,true) '创建文本文件
''''''逐行写入文本''''''
for i =1 to lng
sNew=NewText(s(i))
ss=split(sNew,space(1))
NewFile.writeline ss(0) & "," & ss(1) & ","& ss(2)& ","& ss(3)
next
End Sub
''''''将多个space转换成1个space''''''
Function NewText(txt)
dim r
if instr(txt," ")>0 then
r=replace(txt,space(2),space(1))
do
m=len(r)
r=replace(r,space(2),space(1))
n=len(r)
loop until m=n
NewText=trim(r)
else
msgbox("文本未按空格分隔")
end if
End Function