Follow

How can I change the axes settings in Surfer via automation?

You can change the settings of any axis by accessing each axis through the Axes collection.  For more options for the axes, please see the Axis Object Help topic.
 

For example:

Dim Axes, XAxis As Object
Set Axes = MapFrame.Axes

'Assigns the bottom X axis to the variable named "XAxis", instead of 1 you could use "bottom axis"
Set XAxis = Axes(1)
XAxis.Title = "X Axis Title"

 

A full script example of this process is shown below. 


To run this script:

  1. Copy the script below.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 16\Scripter.
  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 As Object
Set SurferApp = CreateObject("Surfer.Application") SurferApp.Documents.Add(srfDocPlot) SurferApp.Visible = True Infile = SurferApp.Path + "\samples\demogrid.grd" Dim Plot, MapFrame, Axes, Axis As Object Set Plot = SurferApp.Documents.Add Set MapFrame = Plot.Shapes.AddContourMap(GridFileName:=Infile) Set Axes = MapFrame.Axes For Each Axis In Axes Axis.ShowLabels = False Axis.MajorTickType = srfTickNone Axis.MinorTickType = srfTickNone Next Axis End

See also the attached script Axes.bas, which can also be found in the \Samples\Scripts\ folder in the Surfer installation directory.

 

Updated November 1, 2018

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

2 Comments

  • 0
    Avatar
    Kien Pham

    I am looking for definition of the Axes object. If 1 is the bottom axis, how are the rest of the axes defined? Is left axis 2? Feel free to point me to a Help section where the object is defined. 

  • 0
    Avatar
    Brittany Bodane

    Hi Kien,

    Thank you for your post! We spoke earlier over LiveChat, but I wanted to reply as this is a good question and I am sure others will benefit from the answer. 

    The axes objects do not need to be defined. They are predefined in Surfer already as the following in a 2D map:

    BottomAxis

    TopAxis

    LeftAxis

    RightAxis

    In a 3D map, they are defined as the following:

    XAxis

    YAxis

    ZAxis

    Another great example of how to use these objects (including creating variables for them) can be found in the sample script Axes.bas found by default in C:\Program Files\Golden Software\Surfer 16\Samples\Scripts.

    More information can be found in Surfer's Help on the Axis object page that is linked above. 

    Thank you,

    Brittany

    Golden Software Support

Please sign in to leave a comment.