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

Application1

Returns the application object. It is a read-only property

Count1

Returns the number of Shapes. It is a read-only property.

Parent1

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

The following table provides the methods of the Shapes collection:

Method

Description

AddClassedPostLayer

Adds a new classed post map layer to a specified MapFrame object.

AddClassedPostMap2

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.

AddColorReliefLayer

Adds a new color relief layer to a specified MapFrame object.

AddColorReliefLayerXYZC

Adds a new color relief layer to a specified MapFrame object from a slice of 3D grid

AddColorReliefMap

Adds a new color relief map.

AddColorReliefMapXYZC

Adds a new color relief map from a slice of a 3D grid

AddComplexPolygon1

Adds a new complex (included/excluded regions) polygon shape.

AddContourLayer

Adds a new contour map layer to a specified MapFrame object.

AddContourLayerXYZC

Add a new contour layer to a specified MapFrame object from a slice of a 3D grid

AddContourMap

Adds a new contour map.

AddContourMapXYZC

Adds a new contour map from a slice of a 3D grid

AddDataBaseLayer

Adds a new data base layer to a specified MapFrame object.

AddDataBaseMap

Adds a new data base map.

AddEllipse1

Adds a new ellipse shape.

AddEmptyBaseLayer

Adds a new empty base map layer to a specified MapFrame object.

AddEmptyBaseMap

Adds a new empty base map.

AddGraticule

Adds a new graticule to the specified map.

AddLine1

Adds a new line segment.

AddPolygon1

Adds a new simple polygon shape.

AddPolygon3D

Adds a new simple 3D polygon shape.

AddPolyLine1

Adds a new polyline shape.

AddPolyLine21

Adds a new polyline or spline polyline shape.

AddPolyLine3D

Adds a new 3D polyline.

AddPostLayer

Adds a new post map layer to a specified MapFrame object.

AddPostMap

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.

AddPostMap2

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.

AddRangeRing1

Adds a new range ring.

AddRasterBaseLayer

Adds a new base (raster) layer to the specified MapFrame object.

AddRasterBaseMap

Adds a new base (raster) map.

AddRectangle1

Adds a new rectangle or rounded rectangle shape.

AddReliefLayer

Adds a new shaded relief map layer to a specified MapFrame object.

AddReliefMap

Adds a new shaded relief map.

AddSurface

Adds a new Surface plot.

AddSurfaceLayer

Adds a new surface plot to a specified MapFrame object.

AddSurfaceLayerXYZC

Adds a new surface layer to a specified MapFrame object from a slice of a 3D grid.

AddSurfaceMapXYZC

Adds a new surface plot from a slice of a 3D grid

AddSymbol1

Adds a new symbol shape.

AddText1

Adds a new text shape.

AddVariogram

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.

AddVariogram2

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.

AddVectorBaseLayer

Adds a new base (vector) layer to the specified MapFrame object.

AddVectorBaseMap

Adds a new base (vector) map.

AddVectorLayer

Adds a new vector map layer to a specified MapFrame object.

AddVectorLayerXYZC

Adds a new vector map layer to a specified MapFrame object from a slice of a 3D grid.

AddVectorMap

Adds a new vector map.

AddVectorMapXYZC

Adds a new vector map from a slice of a 3D grid

AddViewshedLayer

Adds a new viewshed layer to a specified layer object.

AddWatershedLayer

Adds a new watershed map layer to the specified MapFrame object.

AddWatershedLayerXYZC

Adds a new watershed map layer to the specified MapFrame object from a slice of a 3D grid.

AddWatershedMap

Adds a new watershed map.

AddWatershedMapXYZC

Adds a new watershed map from a slice of a 3D grid.

AddWireframe

Adds a new wireframe plot.

AddWireframeLayer

Adds a new wireframe plot to a specified MapFrame object.

AddWireframeLayerXYZC

Adds a new wireframe plot to a specified MapFrame object from a slice of a 3D grid.

AddWireframeMapXYZC

Adds a new wireframe plot from a slice of a 3D grid.

BlockSelect

Selects all shapes within the specified rectangle.

InvertSelection

Selects all deselected objects, deselects all selected objects.

Item*1

Returns an individual shape.

Paste

Pastes the contents of the clipboard into the collection.

Query

Queries the shapes and returns a Selection collection

SelectAll

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

 

See Also

Base Map from Data

Shape Object