How can I use the Zoom Rectangle command from a Surfer script?

This article contains a sample script for utilizing ZoomRectangle to zoom into the corners of a map layer.

To run this script:

  1. Copy the script below, or download the attached BAS file: ZoomRectangle.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 16.
  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. 

'Zoom Rectangle.bas
'Utilizes ZoomRectangle to zoom into the corners of a map.
Sub Main

'Initializes Surfer
	Set SurferApp = CreateObject("Surfer.Application")
	Dim Doc, Plot As Object
	SurferApp.Visible = True
	Set Plot = SurferApp.Documents.Add(srfDocPlot)

'Creates a contour map from Demogrid.grd
	Set MapFrame = Plot.Shapes.AddContourMap(GridFileName:=SurferApp.Path+"\Samples\Demogrid.grd")

'Sets the corners of the Contours map layer
	TopCorner = MapFrame.Top
	LeftCorner = MapFrame.Left
	BottomCorner = MapFrame.Top - MapFrame.Height
	RightCorner = MapFrame.Left + MapFrame.Width

'Zooms to the small map
	Plot.NewWindow.ZoomRectangle(Left:=LeftCorner, Top:=TopCorner, Right:=RightCorner, Bottom:=BottomCorner)

End Sub


Updated November 8, 2018


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


Please sign in to leave a comment.