How to get terrain


Placed inside ArcMap's VBA, these routines can get either the specified terrain or all the terrains inside a feature dataset.

How to use

  1. Paste the desired function code into ArcMap's VB Editor.
  2. Reference the ESRI GeoDatabaseExtensions Object Library.
  3. Run the function from a calling procedure which sends and receives the required parameters.
[VBA]
Public Function GetTerrainByName(pFDS As IFeatureDataset, sTerrainName As String) As ITerrain
    Dim pFDEC As IFeatureDatasetExtensionContainer
    Set pFDEC = pFDS
    
    Dim pDC As IDatasetContainer3
    Set pDC = pFDEC.FindExtension(esriDTTerrain)
    
    Set GetTerrainByName = pDC.DatasetByName(esriDTTerrain, sTerrainName)
End Function

Public Function GetTerrainsInFeatureDataset(pFDS As IFeatureDataset) As IEnumDataset
    Dim pFDEC As IFeatureDatasetExtensionContainer
    Set pFDEC = pFDS
    
    Dim pDC As IDatasetContainer3
    Set pDC = pFDEC.FindExtension(esriDTTerrain)
    
    Set GetTerrainsInFeatureDataset = pDC.Datasets(esriDTTerrain)
End Function