Shapes Collection
Within Automation, graphic drawing and map objects are called Shapes. The Shapes collection contains all of the drawing and map objects in a document. This object is also used to create new shapes and add them to the collection. Methods exist to enumerate all the shapes in the collection, add objects to the Selection collection, and create new drawing and map shapes.
One of the most common uses of the Shapes collection is to create new shapes. There is a unique method to create each type of shape. For example, to create a contour map use the AddContourMap method, as in:
Sub Main
Dim SurferApp As Object
Set SurferApp = CreateObject("Surfer.Application")
SurferApp.Visible = True
'Create a new, empty plot document
Set Doc = SurferApp.Documents.Add(srfDocPlot)
'Get the Shapes collection
Set Shapes = Doc.Shapes
'Create the contour map
Set MapFrame = Shapes.AddContourMap(GridFileName:=SurferApp.Path+"\Samples\demogrid.grd")
End Sub
The following table provides all the properties of the Shapes collection:
Property |
Description |
Returns the application object. It is a read-only property |
|
Returns the number of Shapes. It is a read-only property. |
|
Returns the parent object. It is a read-only property. |
The following table provides the methods of the Shapes collection:
Method |
Description |
Adds a new classed post map layer to a specified MapFrame object. |
|
Adds a new classed post map. This method should be used instead of AddClassedPostMap method when the worksheet being loaded is an Excel file where the sheet name needs to be specified. It allows specifying any data import options when loading a data file. |
|
Adds a new color relief layer to a specified MapFrame object. |
|
Adds a new color relief layer to a specified MapFrame object from a slice of 3D grid |
|
Adds a new color relief map. |
|
Adds a new color relief map from a slice of a 3D grid |
|
Adds a new complex (included/excluded regions) polygon shape. |
|
Adds a new contour map layer to a specified MapFrame object. |
|
Add a new contour layer to a specified MapFrame object from a slice of a 3D grid |
|
Adds a new contour map. |
|
Adds a new contour map from a slice of a 3D grid |
|
Adds a new data base layer to a specified MapFrame object. |
|
Adds a new data base map. |
|
Adds a new ellipse shape. |
|
Adds a new empty base map layer to a specified MapFrame object. |
|
Adds a new empty base map. |
|
Adds a new graticule to the specified map. |
|
Adds a new line segment. |
|
Adds a new simple polygon shape. |
|
Adds a new simple 3D polygon shape. |
|
Adds a new polyline shape. |
|
Adds a new polyline or spline polyline shape. |
|
Adds a new 3D polyline. |
|
Adds a new post map layer to a specified MapFrame object. |
|
Adds a new post map. The AddPostMap2 command should be used instead of this method, when the worksheet being loaded is an Excel file where the sheet name needs to be specified. |
|
Adds a new post map. This method should be used instead of the AddPostMap method, when the worksheet being loaded is an Excel file where the sheet name needs to be specified. It also allows specifying the data import options when loading a data file, if any. |
|
Adds a new range ring. |
|
Adds a new base (raster) layer to the specified MapFrame object. |
|
Adds a new base (raster) map. |
|
Adds a new rectangle or rounded rectangle shape. |
|
Adds a new shaded relief map layer to a specified MapFrame object. |
|
Adds a new shaded relief map. |
|
Adds a new Surface plot. |
|
Adds a new surface plot to a specified MapFrame object. |
|
Adds a new surface layer to a specified MapFrame object from a slice of a 3D grid. |
|
Adds a new surface plot from a slice of a 3D grid |
|
Adds a new symbol shape. |
|
Adds a new text shape. |
|
Adds a new variogram plot. The AddVariogram2 command should be used instead of this method, when the worksheet being loaded is an Excel file where the sheet name needs to be specified. |
|
Adds a new variogram plot. This method should be used instead of the AddVariogram method, when the worksheet being loaded is an Excel file where the sheet name needs to be specified. It also allows specifying the data import options when loading a data file, if any. |
|
Adds a new base (vector) layer to the specified MapFrame object. |
|
Adds a new base (vector) map. |
|
Adds a new vector map layer to a specified MapFrame object. |
|
Adds a new vector map layer to a specified MapFrame object from a slice of a 3D grid. |
|
Adds a new vector map. |
|
Adds a new vector map from a slice of a 3D grid |
|
Adds a new viewshed layer to a specified layer object. |
|
Adds a new watershed map layer to the specified MapFrame object. |
|
Adds a new watershed map layer to the specified MapFrame object from a slice of a 3D grid. |
|
Adds a new watershed map. |
|
Adds a new watershed map from a slice of a 3D grid. |
|
Adds a new wireframe plot. |
|
Adds a new wireframe plot to a specified MapFrame object. |
|
Adds a new wireframe plot to a specified MapFrame object from a slice of a 3D grid. |
|
Adds a new wireframe plot from a slice of a 3D grid. |
|
Selects all shapes within the specified rectangle. |
|
Selects all deselected objects, deselects all selected objects. |
|
Item*1 |
Returns an individual shape. |
Pastes the contents of the clipboard into the collection. |
|
Queries the shapes and returns a Selection collection |
|
Selects all shapes in the collection. |
Remarks
1 = These properties and methods can be used for objects within a base layer or composite object.
*default method
Example 1
This script displays all the methods and properties in the Shapes collection.
Example 2
The following script demonstrates how the Shapes 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
End Sub