How can I move and size my map from a Surfer script?

This article contains a sample script for resizing and moving maps.

To run this script:

  1. Copy the script below, or download the attached BAS file: sizemove.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.

'This script demonstrates the following:
'	Create a color filled contour map with a color scale
'	Move entire map and color scale to lower left portion of page
Sub Main

'Initialize Surfer
	Dim SurferApp, Plot, MapFrame, ContourLayer As Object
	Set SurferApp = CreateObject("Surfer.Application")
	SurferApp.Visible = True
	Set Plot = SurferApp.Documents.Add

'Define 'Path' as the sample directory
	Path = SurferApp.Path + "\samples\"

'Create contour map from sample file demogrid.grd
	Set MapFrame = Plot.Shapes.AddContourMap(GridFileName:=Path+"demogrid.grd")

'Define 'ContourLayer' as the first layer in the map frame
	Set ContourLayer = MapFrame.Overlays(1)

'Fill contours and show the color scale
	ContourLayer.FillContours = True
	ContourLayer.ShowColorScale = True
'Select contour map and color scale
	MapFrame.Selected = True
	ContourLayer.ColorScale.Selected = True

'Move the contour map and color scale to lower left corner of the page
	Plot.Selection.Left = 1.0
	Plot.Selection.Top = 4.0

'Shrink the contour map and color scale (like click-and-drag in the UI)
	Plot.Selection.Width = 3.5
	Plot.Selection.Height = 3.0
'Deselect All
End Sub


Updated November 6, 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.