Follow

How can I change my map scale via Surfer automation?

This article contains a sample script for changing the scale of the map.

To run this script:

  1. Copy the script below, or download the attached BAS file: MapScale.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 15\Scripter.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. 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.
  6. 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 October 11, 2017

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.