This document is archived and information here might be outdated.  Recommended version.


Set Group Layer Cache Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Set Group Layer Cache Snippet

Set a group layer cache - specify options like consolidation, strict-on-demand mode, cache name etc.

[C#]
///<summary>Set a group layer cache - specify options like consolidation, strict-on-demand mode, cache name etc.</summary>
///    
///<param name="globe">An ESRI.ArcGIS.GlobeCore.IGlobe interface.</param>
///<param name="layerFile">An ESRI.ArcGIS.Carto.ILayerFile interface.</param>
///     
///<remarks></remarks>
public void SetGroupLayerCache(ESRI.ArcGIS.GlobeCore.IGlobe globe, ESRI.ArcGIS.Carto.ILayerFile layerFile)
{
  ESRI.ArcGIS.Carto.ILayer layer=layerFile.Layer;
  if (layer is ESRI.ArcGIS.Carto.IGroupLayer)
  {
    ESRI.ArcGIS.Carto.IGroupLayer groupLayer=layer as ESRI.ArcGIS.Carto.IGroupLayer; // Dynamic Cast
    ESRI.ArcGIS.Analyst3D.IScene scene=globe as ESRI.ArcGIS.Analyst3D.IScene; // Dynamic Cast
    ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties globeLayerProps=new ESRI.ArcGIS.GlobeCore.GlobeLayerPropertiesClass();
    ESRI.ArcGIS.GlobeCore.IGlobeHelperPub globeHelperPub=new ESRI.ArcGIS.GlobeCore.GlobeHelperClass();

    //Call the IGlobeHelperPub.SetGroupLayerCache method
    globeHelperPub.SetGroupLayerCache(groupLayer, true, globe.GlobeDisplay, false, true, "theGroupCacheName", out globeLayerProps);
    scene.AddLayer(layer, true);
    globeLayerProps.ApplyDisplayProperties(layer);
    layerFile.Save();
    globe.GlobeDisplay.RefreshViewers();
  }
}
[Visual Basic .NET]
'''<summary>Set a group layer cache - specify options like consolidation, strict-on-demand mode, cache name etc.</summary>
'''    
'''<param name="globe">An ESRI.ArcGIS.GlobeCore.IGlobe interface.</param>
'''<param name="layerFile">An ESRI.ArcGIS.Carto.ILayerFile interface.</param>
'''     
'''<remarks></remarks>
Public Sub SetGroupLayerCache(ByVal globe As ESRI.ArcGIS.GlobeCore.IGlobe, ByVal layerFile As ESRI.ArcGIS.Carto.ILayerFile)

  Dim layer As ESRI.ArcGIS.Carto.ILayer=layerFile.Layer

  If TypeOf layer Is ESRI.ArcGIS.Carto.IGroupLayer Then

    Dim groupLayer As ESRI.ArcGIS.Carto.IGroupLayer=TryCast(layer, ESRI.ArcGIS.Carto.IGroupLayer) ' Dynamic Cast
    Dim scene As ESRI.ArcGIS.Analyst3D.IScene=TryCast(globe, ESRI.ArcGIS.Analyst3D.IScene) ' Dynamic Cast
    Dim globeLayerProps As ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties=New ESRI.ArcGIS.GlobeCore.GlobeLayerPropertiesClass()
    Dim globeHelperPub As ESRI.ArcGIS.GlobeCore.IGlobeHelperPub=New ESRI.ArcGIS.GlobeCore.GlobeHelperClass()

    'Call the IGlobeHelperPub.SetGroupLayerCache method
    globeHelperPub.SetGroupLayerCache(groupLayer, True, globe.GlobeDisplay, False, True, "theGroupCacheName", globeLayerProps)
    scene.AddLayer(layer, True)
    globeLayerProps.ApplyDisplayProperties(layer)
    layerFile.Save()
    globe.GlobeDisplay.RefreshViewers()

  End If

End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.3DAnalyst
  • ESRI.ArcGIS.Carto
  • ESRI.ArcGIS.GlobeCore