ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapView Class / GetSelectedSlices Method
Example

In This Topic
    GetSelectedSlices Method
    In This Topic
    Returns the collection of voxel slices selected in the TOC.
    Syntax
    Public Function GetSelectedSlices() As IReadOnlyList(Of SliceDefinition)
    public IReadOnlyList<SliceDefinition> GetSelectedSlices()

    Return Value

    The collection of voxel slices selected in the TOC.
    Example
    Get/Set Selected Voxel Assets from the TOC
    {
      var surfaces = MapView.Active.GetSelectedIsosurfaces();
      //set selected w/ MapView.Active.SelectVoxelIsosurface(isoSurface)
      var slices = MapView.Active.GetSelectedSlices();
      //set selected w/ MapView.Active.SelectVoxelSlice(slice)
      var sections = MapView.Active.GetSelectedSections();
      //set selected w/ MapView.Active.SelectVoxelSection(section)
      var locked_sections = MapView.Active.GetSelectedLockedSections();
      //set selected w/ MapView.Active.SelectVoxelLockedSection(locked_section)
    }
    Get Selected Slice in TOC
    {
      // Note: call within QueuedTask.Run()
      {
        var slice = MapView.Active?.GetSelectedSlices()?.FirstOrDefault();
        if (slice != null)
        {
          //Do something with the slice
        }
      }
    }
    Get Voxel Layer for the Selected Slice in TOC
    {
      // Note: call within QueuedTask.Run()
      {
        voxelLayer = null;
        var slice = MapView.Active?.GetSelectedSlices()?.FirstOrDefault();
        if (slice != null)
        {
          voxelLayer = slice.Layer;
          //TODO - use the layer
        }
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also