Layer 3D Properties

Created:12/11/2000
Description:

To control any of the properties for a layer that are found on the Base Heights, Extrusion, or Rendering tabs of the layer property sheet in ArcScene, you can use the I3DProperties interface which is implemented by several co-classes associated with the layer: Basic3DProperties, Feature3DProperties, Raster3DProperties, and Tin3DProperties. These are known as layer extensions.

How to use:
  1. Add a feature layer to ArcScene.
  2. Paste the code into ArcScene's VB Editor.
  3. Run the procedure.
Public Sub AccessLayer3DProperties()
    ' in ArcScene VBA...
    ' get the document
    Dim pSxDoc As ISxDocument
    Set pSxDoc = Application.Document
    
    ' get the Scene from the Document:
    Dim pScene As IScene
    Set pScene = pSxDoc.Scene
    
    ' get a layer in the scene (assumes there is one)
    Dim pLayer As ILayer
    Set pLayer = pScene.Layer(0)
    
    ' get layer extensions:
    Dim pLayerExts As ILayerExtensions
    Set pLayerExts = pLayer
    
    ' get 3d properties from extension:
    ' layer must have it if it is in scene:
    Dim i As Long
    Dim p3DProps As I3DProperties
    For i = 0 To pLayerExts.ExtensionCount - 1
        If TypeOf pLayerExts.Extension(i) Is I3DProperties Then
            Set p3DProps = pLayerExts.Extension(i)
            Exit For
        End If
    Next

    ' set the layer's base height property to an expression
    ' that equals an item multiplied by a constant.
    ' This case assumes we have a feature layer with an item
    ' called [HEIGHT]
    p3DProps.BaseOption = esriBaseExpression
    p3DProps.BaseExpressionString = "[HEIGHT] * 3.28 "
    
    ' Tell the scene graph to invalidate the layer and redraw:
    Dim pSG As ISceneGraph
    Set pSG = pScene.SceneGraph
    pSG.Invalidate pLayer, True, True
    pSG.RefreshViewers

End Sub