If you have an existing SRF file with a contour map and you just want to change out the grid file and save to a new file, you can use the script below to do it.
To run this script:
- Copy the script below, or download the attached BAS file: ZoomRectangle.bas.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 14\Scripter.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
- Click Script | Run to run the script.
Sub Main 'Initializes Surfer Dim SurferApp, Docs, Plot, Overlays, ContourLayer As Object Set SurferApp = CreateObject("Surfer.Application") SurferApp.Visible = True '======================================== 'User Defined Variables '======================================== FilePath$ = SurferApp.Path+"\Samples\ SRFFile$ = "Axes.srf" GRDFile$ = "demogrid.grd" OutFile$ = "Axes_demogrid.srf" mapnum = 1 'If there are more than one map in the project, specify which map to choose. 'Either use numbers where 1 is the bottom map in the Contents window, or use the entire map name in double quotes (i.e. "Map") layernum=1 'If there are more than one layer in the map, specify which layer to choose. 1 is the bottom layer in the map in the Contents window. 'Either use numbers where 1 is the bottom map in the Contents window, or use the entire map name in double quotes (i.e. "Contours-demogrid.grd") '======================================== 'Assigns the Documents collection to the variable named "Docs" Set Docs = SurferApp.Documents 'Opens the original SRF file and assigns the plot document to the variable named "Plot" Set Plot = Docs.Open(FileName:=FilePath$+SRFFile$) 'Assigns the Contours map layer to the variable named "ContourLayer" Set ContourLayer = Plot.Shapes.Item(mapnum).Overlays.Item(layernum) 'Changes the grid file for the contour layer to a different GRD file ContourLayer.GridFile=FilePath$+GRDFile$ 'Saves the SRF file to a new name Plot.SaveAs(FileName:=FilePath$+OutFile$) End Sub