Yes, you can write a script for looping through the process of gridding, contouring, and printing out separate data files that are saved with consecutive names (i.e. datafile1.dat, datafile2.dat, etc). A sample script demonstrating this is shown below.
To run this script:
- Copy the script below, or download the attached BAS file: Loop-ConsecutiveDataFileName.bas.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer.
- 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 Dim SurferApp As Object Set SurferApp = CreateObject("Surfer.Application") SurferApp.Visible = True 'This starts a loop to grid, contour, and print out 5 separate data files 'that have consecutive names such as datafile1.dat, datafile2.dat, etc. For i = 1 To 3 'Opens a new plot document Dim Plot As Object Set Plot = SurferApp.Documents.Add 'Specifies the path to the data file Path = "c:\temp\SAMPLE"+Format(i) 'Create a grid from the data file SurferApp.GridData(DataFile:=Path+".DAT", OutGrid:=Path+".grd") 'Creates a contour map from the grid file Dim Map As Object Set Map = Plot.Shapes.AddContourMap(GridFileName:=Path+".grd") 'Prints the plot document Plot.PrintOut Next i End Sub
Updated November 13, 2018
Comments
4 comments
The code works great. Thank you.
Is there a way to have the contours added to the same plot insteading of generating new plot for during each i in the loop?
Is there a way to modify the placement of the contour in the plot window within the loop?
Hi Kien,
You could us something like this to add the contour layers to the existing map:
You could add a line in the loop to move the map (see below), but it doesn't make sense to do so for the above script, since you just have one map rather than multiple maps:
Thanks,
Leslie
I am looking to add to this loop the automation of transformation, setting the x scale and z scale within each i data set. Can someone help?
Hi Kien,
You can use the zLength command or the zMapPerPU command for the MapFrame object to set the Z scale, and you can use the xLength command or the xMapPerPU command to set the X scale. Put these in the loop with a defined number to set the same size for all maps, or use the loop variable (i) in an equation to vary the size.
Thanks,
Leslie
Please sign in to leave a comment.