Follow

How can I set the opacity/transparency of an object in Surfer automation?

Use the .Opacity property of the object to specify the opacity (or transparency) of the object in automation. You can set the opacity for layer properties, the layers themselves, and for other drawn objects. Below is a full example script demonstrating this process. 

 

To run this script:

  1. Copy the script below.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 14\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 it into Scripter. 
  6. Click Script | Run to run the script.
     

*********

Sub Main

    Dim SurferApp As Object
    Set SurferApp = CreateObject("Surfer.Application")
    SurferApp.Visible = True

    Dim Plot As Object
    Set Plot = SurferApp.Documents.Add

'Creates a filled image map, and sets the opacity of the missing data fill to 0% (completely transparent)
    Dim MapFrame1 As Object
    Set MapFrame1 = Plot.Shapes.AddImageMap(GridFileName:=SurferApp.Path+"\samples\goldenblank1.grd")
    Dim ImageLayer As Object
    Set ImageLayer = MapFrame1.Overlays(1)

'Sets opacity for the missing data in the image layer properties
    ImageLayer.MissingDataColorRGBA.Opacity=0

'Sets the opacity for the image layer iteself
    ImageLayer.Opacity = 50

'Creates a polygon and fills it with a semi-opaque fill
    Dim Coordinates(5) As Double
    Coordinates(0) = 4: Coordinates(1) = 4
    Coordinates(2) = 8: Coordinates(3) = 1
    Coordinates(4) = 5.5: Coordinates(5) = 0.5

    Set Polygon = Plot.Shapes.AddPolygon(Coordinates)
    Polygon.Fill.Pattern = "Solid"
    Polygon.Fill.ForeColorRGBA.Color = srfColorBlue
    Polygon.Fill.ForeColorRGBA.Opacity = 50

End Sub

 

For more information, please see the Opacity Property page in the Help. See also the attached script Opacity.bas, which is also located in the \Samples\Scripts\ folder in the Surfer installation directory.

 

Updated February 14, 2017

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.