Follow

How can I hide a map layer in Surfer's automation?

This article contains a sample script for turning off the visibility of a map layer.

To run this script:

  1. Copy the script below, or download the attached BAS file: Visibility of Map Layer OFF.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\GoldenSoftware\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.   

'===================================
'Visibility of Map Layer OFF.bas
'===================================
'Shows how to turn off the visibility of a map layer, similar to unchecking
'the checkbox in the Contents window next to the map layer in the UI.
'===================================
Sub Main

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

'Creates two post maps
	Set MapFrame = Plot.Shapes.AddPostMap(SurferApp.Path + "\samples\demogrid.dat")
	Set MapFrame2 = Plot.Shapes.AddPostMap(SurferApp.Path + "\samples\sample1.dat")

'Overlays the two post maps
	Plot.Shapes.SelectAll
	Plot.Selection.OverlayMaps
	Plot.Selection.DeselectAll
	
'Turns off the visibility of the second post layer
	Set NewMapFrame = Plot.Shapes.Item(1)
	Set PostLayer2 = NewMapFrame.Overlays(2)
	PostLayer2.Visible = False

End Sub

 

Updated November 6, 2018

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

0 Comments

Please sign in to leave a comment.