PlotDocument Object Script

This script demonstrates all the methods and properties in the PlotDocument object. If you wish to run the script, open Scripter and then open PlotDocumentObject.bas from the Surfer Samples folder.

' PlotDocumentObject.bas demonstrates the properties and

' methods of the Plot Document Object.

Sub Main

Dim SurferApp As Object

Set SurferApp = CreateObject("Surfer.Application")

SurferApp.Visible = True

Dim Plot As Object

Set Plot = SurferApp.Documents.Add(srfDocPlot)

'Creates and selectes a base map

Set MapFrame1 = Plot.Shapes.AddBaseMap(ImportFileName:=SurferApp.Path+"\samples\demogrid.tif")

MapFrame1.Select

'Set the default Fill color and pattern, return the default fill pattern

Plot.DefaultFill.ForeColorRGBA.Color = srfColorMagenta

Plot.DefaultFill.Pattern = "Checkerboard"

Debug.Print "default fill pattern: "; Plot.DefaultFill.Pattern

'Set the default Font color, return the default font face

Plot.DefaultFont.ForeColorRGBA.Color = srfColorBlue

Debug.Print "default font face: "; Plot.DefaultFont.Face

'Set the default Line color, return the default line style

Plot.DefaultLine.ForeColorRGBA.Color = srfColorBrown

Debug.Print "default line style: "; Plot.DefaultLine.Style

'Set the default Symbol size, return the default symbol index

Plot.DefaultSymbol.Size = 0.5

Debug.Print "default symbol index: "; Plot.DefaultSymbol.Index

'Set the Default page margin, return the default page orientation

Plot.PageSetup.RightMargin = 1

Debug.Print "default page orientation "; Plot.PageSetup.Orientation

'Return the number of selected objects

Debug.Print "number of selected objects: "; Plot.Selection.Count

'Create a rectangle in the plot document

Dim Rectangle As Object

Set Rectangle = Plot.Shapes.AddRectangle(Left:=5, Top:=7, Right:=6, Bottom:=10)

'Hides the Contents Window

Plot.ShowContentsWindow = False

'Hides the Properties Window

Plot.ShowPropertiesWindow = False

'Imports

Plot.Import2(FileName:=SurferApp.Path+"\Samples\ca2000.gsb", Options:="Defaults=1" , FilterId:= "gsb")

'Exports the plot document window to a vector PDF file

Plot.Export2 (FileName:=SurferApp.Path+"\Samples\Export.pdf", FilterId:="pdfv")

'Prints the plot document window

Plot.PrintOut

End Sub