When preparing maps for analysis, presentation or publication, proper scaling is key. The automated methods available to control map scale in a script are outlined in the sample script below.
To run this script:
- Copy the script below, or download the attached BAS file: MapScale.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.
'========================================================================== 'MAPSCALE.BAS ' 'This script demonstrates the following: ' ' Create a wireframe and a contour map ' Overlay two maps ' Change the X, Y, and Z scale for the maps ' '========================================================================== Sub Main 'Declare the variable that will reference the application Dim SurferApp As Object 'Creates an instance of the Surfer Application object ' and assigns it to the variable named "SurferApp" Set SurferApp = CreateObject("Surfer.Application") 'Assigns the location of the data and grid files to the variable "Path" Path = SurferApp.Path + "\samples\" 'Makes Surfer visible SurferApp.Visible = True 'Declares Doc as Object Dim Doc As Object 'Creates a plot document in Surfer and assigns it to the variable "Doc" Set Doc = SurferApp.Documents.Add 'Declares MapFrame1 as object Dim MapFrame1 As Object 'Creates a wireframe map and assigns the map frame to the variable "MapFrame1" Set MapFrame1 = Doc.Shapes.AddWireframe(GridFileName:=Path+"demogrid.grd") 'Declares MapFrame2 as object Dim MapFrame2 As Object 'Creates a contour map and assigns the map frame to the variable "MapFrame2" Set MapFrame2 = Doc.Shapes.AddContourMap(GridFileName:=Path+"demogrid.grd") 'Select both Maps MapFrame1.Selected = True MapFrame2.Selected = True 'Overlay the selected maps and save the new map frame Dim MapFrame As Object Set MapFrame = Doc.Selection.OverlayMaps 'Change the map scale MapFrame.xMapPerPU = 0.5 MapFrame.yMapPerPU = 0.5 MapFrame.zMapPerPU = 20 'Declares Plot as Object Dim Plot As Object 'Assigns the first (and only) plot window To the variable "Plot" Set Plot = Doc.Windows(1) 'Change the view so the entire map fits on the screen Plot.Zoom(srfGridZoomFitToWindow) End Sub
Updated November 2021
Thank you for posting your questions! I am happy you found how to automat setting the X and Y scale inputs in the Transform menu.
Regarding your new question, The Proportional XY Scaling option is automatically turned off if you set the Map scale to lengths that are not proportional. Thus, there is no method to uncheck this option. If you only establish a length for the X, Y, or Z, Surfer assumes you would like to keep the map proportionally scaled. Otherwise, it will take the lengths stated in the script. For example, the script below will change the X,Y, and Z scales to disproportionate scaling:
Another sample script you may be interested in seeing in located by default in C:\Program Files\Golden Software\Surfer <version number>\Samples\Scripts and is named MapFrame.bas
Please let us know if you have any further questions.
It seems to me that the per unit settings don't behave the same as the scale input in the Transform menu. Is there a way to automate setting specifically the X and Y scale inputs in the Transform menu?
EDIT: I was actually able to figure out the scaling I want using the MapPerPU properties. However, I have not figured out how to turn off Proportional XY scaling via automation. Please help on that.
Please sign in to leave a comment.