HOW TO

Get the minimum and maximum elevation for a tin using ArcObjects

Last Published: April 25, 2020

Summary

This article contains a code sample that returns the minimum and maximum elevations for a tin.

Procedure



  1. Open ArcMap.
  2. Open the Visual Basic Editor.

    In ArcMap, select Tools > Macros > Visual Basic Editor.

  3. In the Project Explorer window, expand Project.mxt and select ArcMap Objects > ThisDocument. Right-click and select View Code.
    [O-Image] Visual Basic Project  Explorer
    Note:
    Code in ThisDocument code module will only run in the current map document. To store the code in all map documents, open the code in the Normal.mxt ThisDocument code module.

  4. Paste the following code into the code module.

    Code:
    Sub GetElev()
    Dim pDoc As IMxDocument
    Set pDoc = ThisDocument
    Dim pTinLayer As ITinLayer
    Set pTinLayer = pDoc.SelectedLayer
    Dim pEnv As IEnvelope
    Dim zMin As Double
    Dim zMax As Double

    Set pEnv = pTinLayer.Dataset.Extent
    zMin = pEnv.zMin
    zMax = pEnv.zMax
    MsgBox "Minimum elevation :" & zMin & vbNewLine & _
    "Maximum elevation :" & zMax
    End Sub

  5. Close the Visual Basic Editor.
  6. Add tin data to ArcMap.
  7. Select the tin layer.
  8. Run the code.

    A. Click Tools > Macros > Macros to display the Macros dialog box.
    B. Select a macro and click Run.

Article ID:000004970

Software:
  • ArcMap 8 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic