Placed inside ArcMap's VBA, these routines can get either the specified terrain or all the terrains inside a feature dataset.
How to use
- Paste the desired function code into ArcMap's VB Editor.
- Reference the ESRI GeoDatabaseExtensions Object Library.
- Run the function from a calling procedure which sends and receives the required parameters.
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