How can I name my Surfer map in a script?

This article contains a sample script for naming the map frame and contour map objects.

To run this script:

  1. Copy the script below, or download the attached BAS file: naming.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:
'	Shows how to use Shape.Name =, 
'			overlay objects, 
'			use the SetZOrder command

Sub Main
	Dim SurferApp As Object
	Set SurferApp = CreateObject("Surfer.Application")
	SurferApp.Visible = True
'Set path
	Dim Plot As Object
	Set Plot = SurferApp.Documents.Add
'Creates a contour map & assigns the map frame to the variable "MapFrame"
	Dim MapFrame1 As Object
	Set MapFrame1 = Plot.Shapes.AddContourMap(GridFileName:=Path+"demogrid.grd")
'Assigns the contour overlay to the variable "ContourMap" for easier access
	Dim ContourMap As Object
	Set ContourMap = MapFrame1.Overlays(1)
'Name contour map layer
	ContourMap.Name = "Contour Map"
'Creates a post map & assigns the map frame to the variable "MapFrame2"
	Dim MapFrame2 As Object
	Set MapFrame2 = Plot.Shapes.AddPostMap(DataFileName:=Path+"demogrid.dat")

'Assigns the post map overlay to the variable "PostMap" for easier access
	Dim PostMap As Object
	Set PostMap = MapFrame2.Overlays(1)
'Name post map overlay (right side of colon)
	PostMap.Name = "Post Map"
'Select map objects
	MapFrame1.Selected = True
	MapFrame2.Selected = True
'Overlay selected maps
	Set NewMapFrame = Plot.Selection.OverlayMaps

'Name the map frame
	NewMapFrame.Name = "Demogrid"

'Arrange map objects
End Sub


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