How can I break a map layer out of the map in Surfer Scripter?

This article contains a sample script for breaking a map layer out of the map frame.

To run this script:

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


Sub Main

'Declare the variable that will reference the application
	Dim SurferApp As Object
	Set SurferApp = CreateObject("Surfer.Application")
	SurferApp.Visible = True

'Declares Plot as an object
	Dim Plot As Object
	Set Plot = SurferApp.Documents.Add

'Declares MapFrame as Object
	Dim MapFrame1 As Object

'Creates surface map and assigns the map frame to the variable "MapFrame1"
	Set MapFrame1 = Plot.Shapes.AddSurface(GridFileName:=SurferApp.Path+"\samples\demogrid.grd")

'Creates a contour map and assigns the map frame to the variable "MapFrame2"
	Set MapFrame2 = Plot.Shapes.AddContourMap(GridFileName:=SurferApp.Path+"\samples\demogrid.grd")
	Dim ContourLayer As Object
	Set ContourLayer = MapFrame2.Overlays(1)

'Creates a post map and assigns the map frame to the variable "MapFrame3"
	Set MapFrame3 = Plot.Shapes.AddPostMap (SurferApp.Path+"\samples\demogrid.dat")
	Dim PostLayer As Object
	Set PostLayer = MapFrame3.Overlays(1)

'Selects the three maps
	MapFrame1.Selected = True
	MapFrame2.Selected = True
	MapFrame3.Selected = True

'Overlays the maps and set the overlay to NewMapFrame
	Set NewMapFrame = Plot.Selection.OverlayMaps

'Breaks apart the overlay and sets the new map frame to NewMapFrame2
'For more overlay options, see Overlays Collection
	Set NewMapFrame2 = NewMapFrame.Overlays.BreakApart(pOverlay:=ContourLayer)

End Sub



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