Selection Collection

The Selection collection contains all the properties and methods associated with the collection of selected shapes. The Selection collection defines methods that operate on one or more selected shapes. Most commands within Surfer that require selected objects are part of the Selection collection.

To select a particular shape, set the shape’s Selected property to True. When a Shape object is selected, it is added to the Selection collection. When it is deselected, it is removed from the Selection collection. Note that the shape is neither created nor destroyed by selection operations. It is merely added or removed from the Selection collection.

The Selection collection allows all selected shapes to be enumerated, and contains most methods that operate on multiple objects. This includes moving and sizing one or more shapes; cut, copy, and paste; and overlaying and stacking multiple maps.

The following table provides all properties of Selection collection:

Property

Description

Application

Returns the application object. Its a read-only property

Count

Returns the number of shapes in the selection. It is a read only property.

Height

Returns/sets the height of the selection.

Left

Returns/sets the coordinate for the left edge of the selection.

Parent

Returns the parent object. It is a read only property.

Top

Returns/sets the coordinate for the top edge of the selection.

Width

Returns/sets the width of the selection.

The following table provides the methods of the Selection collection:

Method

Description

Align

Aligns the objects in the selection.

BreakAtIntersections

Break the selected polyline(s) at intersections with the other selected objects.

Buffer

Adds one or more buffer polygons around the selected object(s).

ChangeType

Convert objects from one type into another type.

Combine

Combine the selected objects into a single composite object.

CombineIslandsLakes

Combine selected polygons into a single complex polygon.

CombinePolygons

Combines selected polygons and creates a union, intersection, or difference of polygons.

ConnectPolylines

Connect two or more polylines to create a single polyline.

Copy

Copies the selection to the clipboard.

CreateIntersectionPoints

Create points at the intersections of selected objects.

Cut

Cuts the selection to the clipboard.

Delete

Deletes the selected objects.

DeselectAll

Deselects all objects in the selection.

Item*

Returns an individual shape.

LineSmoothing

Add vertices to a line or polygon to smooth the shape.

LineThinning

Remove unnecessary vertices from a line or polygon.

OverlayMaps

Overlays all maps in the selection.

Rotate

Rotates the selected objects by the specified number of degrees.

SetZOrder

Move the selected objects forward or backward in the Z (drawing) order.

Size

Sizes the selected objects to the same width and/or height of the reference object.

SplitIslandsLakes

Split a complex polygon into separate simple polygons.

StackMaps

Stacks all maps in the selection.

*default method

Example

The following script demonstrates how the Selection collection is used in reference to the PlotDocument object.

Sub Main

 

'Declares SurferApp as an object

Dim SurferApp As Object

 

'Creates an instance of the Surfer Application object and assigns

'it to the variable named "SurferApp"

Set SurferApp = CreateObject("Surfer.Application")

 

'Makes Surfer visible

SurferApp.Visible = True

 

'Declares Plot as an object

Dim Plot As Object

 

'Creates a plot document in Surfer and assigns it to the variable

'named "Plot"

Set Plot = SurferApp.Documents.Add(srfDocPlot)

 

'Declares Shapes as an object

Dim Shapes As Object

 

'Assigns the Shapes collection to the variable named "Shapes"

Set Shapes = Plot.Shapes

 

'Declares MapFrame as an object

Dim MapFrame As Object

 

'Creates a contour map and assigns the map coordinate system to

'the variable named "MapFrame"

Set MapFrame = Shapes.AddContourMap(GridFileName:=SurferApp.Path+"\Samples\demogrid.grd")

 

'Declares ContourLayer as an object

Dim ContourLayer As Object

 

'Assigns the contour map properties to the variable named

'"ContourLayer"

Set ContourLayer = MapFrame.Overlays(1)

 

'Declares Ellipse as an object

Dim Ellipse As Object

 

'Creates an ellipse and assigns it the variable named "Ellipse"

Set Ellipse = Shapes.AddEllipse(Left:=5, Top:=7, Right:=6,Bottom:=10)

 

'Selects both the contour map and the ellipse. This results

'with both objects also belonging to the Selection collection

Shapes.SelectAll

 

'Declares Selection as an object

Dim Selection As Object

Set Selection = Plot.Selection

 

End Sub