Surfer names all new MapFrames "Map" by default. If you're creating a document with multiple maps changing the name of each new map makes applying properties much easier to manage in a script. The sample script below shows how to name the map frame and individual map layers.
To run this script:
- Copy the script below, or download the attached BAS file: naming.bas.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- 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.
- Click Script | Run to run the script.
*********
'============================================================================ 'NAMING.BAS ' '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 Path=SurferApp.Path+"\Samples\" 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 ContourMap.SetZOrder(Zorder:=srfZOToFront) End Sub
Updated November 2021
Comments
0 comments
Please sign in to leave a comment.