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 |
Returns the application object. Its a read-only property |
|
Returns the number of shapes in the selection. It is a read only property. |
|
Returns/sets the height of the selection. |
|
Returns/sets the coordinate for the left edge of the selection. |
|
Returns the parent object. It is a read only property. |
|
Returns/sets the coordinate for the top edge of the selection. |
|
Returns/sets the width of the selection. |
The following table provides the methods of the Selection collection:
Method |
Description |
Aligns the objects in the selection. |
|
Break the selected polyline(s) at intersections with the other selected objects. |
|
Adds one or more buffer polygons around the selected object(s). |
|
Convert objects from one type into another type. |
|
Combine the selected objects into a single composite object. |
|
Combine selected polygons into a single complex polygon. |
|
Combines selected polygons and creates a union, intersection, or difference of polygons. |
|
Connect two or more polylines to create a single polyline. |
|
Copies the selection to the clipboard. |
|
Create points at the intersections of selected objects. |
|
Cuts the selection to the clipboard. |
|
Deletes the selected objects. |
|
Deselects all objects in the selection. |
|
Item* |
Returns an individual shape. |
Add vertices to a line or polygon to smooth the shape. |
|
Remove unnecessary vertices from a line or polygon. |
|
Overlays all maps in the selection. |
|
Rotates the selected objects by the specified number of degrees. |
|
Move the selected objects forward or backward in the Z (drawing) order. |
|
Sizes the selected objects to the same width and/or height of the reference object. |
|
Split a complex polygon into separate simple polygons. |
|
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