'This script shows how to set the opacity of the misisng data color of an image map,
'how to set the opacity of the image map layer itself,
'and how to set the opacity of the contour levels in a contour map

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 ImageLayer As Object
	Set ImageLayer = MapFrame1.Overlays(1)
	ImageLayer.MissingDataColorRGBA.Opacity=0

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

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

'Set the level method to Advanced to allow access to individual levels
	ContourLayer.LevelMethod = SrfConLevelMethodAdvanced

'Fill contours
	ContourLayer.FillContours = True

'Load a CLR file for the color fill of the contour map
	ContourLayer.FillForegroundColorMap.LoadFile(SurferApp.Path+"\ColorScales\Rainbow.clr")
	ContourLayer.ApplyFillToLevels(1, 1, 0)

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

'Sets the opacity for the 9th level in the contour map to 15%
	ContourLayer.Levels(9).Fill.ForeColorRGBA.Opacity = 15

End Sub
