Move and size a map from via Surfer automation

Adjusting the position and size of objects is one of the easiest things to do in the Surfer user interface.  The same actions are a little trickier to perform via automation.  The sample script below demonstrates how to select and move objects via automation.

Note that if you need to resize your map, the best practice is to adjust the map scale as shown in the article Change the map scale via Surfer automation.

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.
  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 2021

Was this article helpful?
1 out of 1 found this helpful



Please sign in to leave a comment.