[Visual Basic 6.0]The example shows how to get the Geometry properties for a selected polygon in an ArcMap edit session.
Public Sub t_IGeometry_polygon() Dim pID As New UID pID = "esriEditor.editor" Dim pEditor As IEditor Dim pApp As IApplication Set pApp = Application Set pEditor = pApp.FindExtensionByCLSID(pID) If pEditor.SelectionCount <> 1 Then MsgBox "select one polygon" Exit Sub End If Dim pEnumFeat As IEnumFeature Dim pFeature As IFeature Set pEnumFeat = pEditor.EditSelection Dim pGeometry As IGeometry Set pFeature = pEnumFeat.Next While Not pFeature Is Nothing If pFeature.Shape.GeometryType = esriGeometryPolygon Then Set pGeometry = pFeature.Shape MsgBox "+++Polygon::IGeometry properties..." & vbCrLf _ & "Dimension = " & pGeometry.Dimension & vbCrLf _ & "Geometry type = " & pGeometry.GeometryType & vbCrLf _ & "Envelope = " & pGeometry.Envelope.XMin & "," & pGeometry.Envelope.YMin & "," _ & pGeometry.Envelope.XMax & "," & pGeometry.Envelope.YMin & vbCrLf _ & "IsEmpty = " & pGeometry.IsEmpty & vbCrLf _ & "SpatialReference = " & pGeometry.SpatialReference.Name End If Set pFeature = pEnumFeat.Next Wend End Sub
[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button
in the upper-left corner of the page.