Assign names to overlaid layers in a map via Surfer automation

When overlaying multiple layers into a single map, you may want to name them so that they are easier to call for later manipulation.  There are two steps to naming your maps in Surfer Scripter:
  1. Name the  Map "frame" that holds the layers and axes (e.g. called Map in the user interface)
  2. Name the "overlays", which are the actual map layers (e.g. called Contours or Base in the user interface)

 

The script below shows how to use the .Name property of the Shape object to rename a layer or map object. 

 

To run this script:

  1. Copy the script below, or download the attached BAS file: AssignName.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. Press Ctrl+V to paste the script into Scripter.
  6. Click Script | Run to run the script.
     

*********

Sub Main
    Dim SurferApp, Plot, MapFrame1, ContourLayer, MapFrame2, PostLayer As Object
    Set SurferApp = CreateObject("Surfer.Application")
    SurferApp.Visible = True

    'Set path
    Path=SurferApp.Path+"\Samples\"

    Set Plot = SurferApp.Documents.Add

    'Creates a contour map
    Set MapFrame1 = Plot.Shapes.AddContourMap(GridFileName:=Path+"demogrid.grd")
    Set ContourLayer = MapFrame1.Overlays(1)

    'Name the contour layer
    ContourLayer.Name = "This is My Contour Layer"

    'Creates a post map
    Set MapFrame2 = Plot.Shapes.AddPostMap(DataFileName:=Path+"demogrid.dat")
    Set PostLayer = MapFrame2.Overlays(1)

    'Name the post layer
    PostLayer.Name = "This is My Post Layer"

    'Select and overlays the map objects
    MapFrame1.Selected = True
    MapFrame2.Selected = True
    Set NewMapFrame = Plot.Selection.OverlayMaps

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

End Sub

 

Updated November 2021

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

Comments

0 comments

Please sign in to leave a comment.