Knowledgebase Home | Contact Knowledgebase Home| Contact
Search the Knowledgebase Browse by Category
How can I set the opacity/transparency of an object in automation?
User Opinions
No users have voted.

How would you rate this answer?
Helpful
Not helpful
Use the object.Opacity property of the object to specify the opacity (or transparency) of the object in automation.

For more information, please see Help | Surfer Automation Help | List of Methods and Properties | Opacity Property.

The example below creates a blanked image map and a filled contour map. It sets the opacity of the missing data of the image map, the opacity of the image map layer itself, and the opacity of the contour map color fill.

*****

Sub Main

'Declare the variable that will reference the application
    Dim SurferApp As Object
    Set SurferApp = CreateObject("Surfer.Application")
    SurferApp.Visible = True

'Declares Plot as an object
    Dim Plot As Object
    Set Plot = SurferApp.Documents.Add

'Creates a blanked grid
    SurferApp.GridBlank(SurferApp.Path+"/samples/demogrid.grd",SurferApp.Path+"/samples/demorect.bln",SurferApp.Path+"/samples/demoblanked2.grd")

'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\demoblanked2.grd")
    Dim ImageMap As Object
    Set ImageMap = MapFrame1.Overlays(1)
    ImageMap.MissingDataColorRGBA.Opacity=0

'Sets the opacity for the image map layer to be 50%
    ImageMap.Opacity = 50

'Creates a contour map
    Dim MapFrame2 As Object
    Set MapFrame2 = Plot.Shapes.AddContourMap(GridFileName:=SurferApp.Path+"\samples\demogrid.grd")
    Dim ContourMap As Object
    Set ContourMap = MapFrame2.Overlays(1)

'Fill contours
    ContourMap.FillContours = True

'Returns the Levels collection object.
    Set Levels = ContourMap.Levels

'Set the level fill color with a gradation from blue to red
    n = Levels.Count
    ColorInc = 255.0 / (n-1)
    For i=1 To n
       ColorInc = 255.0 * (i-1) / (n-1)
       Levels(i).Fill.ForeColor = RGB(ColorInc,0,255-ColorInc)
    Next i

'Specifies the opacity for the color fill for all levels in the contour map to 30%
    n = Levels.Count
    For i=1 To n
       Levels(i).Fill.ForeColorRGBA.Opacity = 30
    Next i

End Sub

Visitor Comments
No visitor comments posted. Post a comment
Related Questions
Attachments
No attachments were found.
Post Comment for "How can I set the opacity/transparency of an object in automation?"
To post a comment for this question, simply complete the form below. Fields marked with an asterisk are required.
   Name:
   Email:
* Comment:
Continue
Powered by ActiveKB Knowledgebase Software

Home * Products * Gallery * Support * About Us * Register * Order * Demos