Saturday, August 23, 2008

Surfer

' Copyright: http://scriptdemo.blogspot.com
'曾经几次试图看 Surfer 脚本的写法,总是没有动力地夭折了。终于逮住个机会完整地看了一个。再实践操作了几遍,也算入了门了。
'第一步启动Surfer
Sub main
Dim SurferApp As Object
Dim Doc As Object
Dim Plotwindow As Object
Dim ContourMapFrame As Object
Dim ContourMap As Object
Set SurferApp = CreateObject("Surfer.Application")
SurferApp.Visible=True
'第二步数据导入处理:
path="D:\Program Files\Golden Software\Surfer8\test"
Infile1= path + "1.dat"
OutFile1= path + "1.grd"
retValue = SurferApp.GridData(DataFile:=InFile1, xCol:=1, yCol:=2, zCol:=zlist, _
                         Algorithm:=srfKriging, ShowReport:=False, OutGrid:=OutFile1)
'第三步打开绘图窗口:
Set Doc = SurferApp.Documents.Add(srfDocPlot)
Set Plotwindow=Doc.Windows(1)
Plotwindow.AutoRedraw = False
Set ContourMapFrame =Doc.Shapes.AddContourMap(OutFile1)
Set ContourMap = ContourMapFrame.Overlays(1)
'修改部分属性:
ContourMap.FillContours = True
ContourMap.ShowColorScale = False
ContourMap.SmoothContours = srfConSmoothMed
ContourMap.BlankFill.Pattern = "Water"
ContourMap.BlankFill.ForeColor = srfColorOrange
ContourMap.BlankFill.BackColor = srfColorWhite
'等等
'第四步:输出图象,退出Surfer
OutFig= path + "aa.gif"
 Doc.Export(filename:=outfig,Options:="Width=800, Height=600")
 Plotwindow.Close
 SurferApp.Quit
End Sub
其它属性以及功能可以参考help文件进行添加修改,可以做的事情还是很多的,语法基本上与vb一样。

No comments:

ShowCalendar