ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapView Class / GetSelectedSections Method
Example

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

    Return Value

    The collection of voxel sections 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 the Selected Section in TOC
    //var voxelLayer = ... ;
    //Must be on the QueuedTask.Run()
    
    var section = MapView.Active?.GetSelectedSections()?.FirstOrDefault();
    if (section != null)
    {
    
    }
    
    Get Voxel Layer for the Selected Section in TOC
    //var voxelLayer = ... ;
    //Must be on the QueuedTask.Run()
    
    VoxelLayer voxelLayer = null;
    var section = MapView.Active?.GetSelectedSections()?.FirstOrDefault();
    if (section != null)
    {
        voxelLayer = section.Layer;
        //TODO - use the layer
    }
    
    Lock a Section/"Create" a Locked Section
          //var voxelLayer = ... ;
          //Must be on the QueuedTask.Run()
    
          if (voxelLayer.Visualization != VoxelVisualization.Surface)
              voxelLayer.SetVisualization(VoxelVisualization.Surface);
          voxelLayer.SetSectionContainerExpanded(true);
          voxelLayer.SetLockedSectionContainerExpanded(true);
          voxelLayer.SetLockedSectionContainerVisibility(true);
    
          //Use the SelectedVariableProfile to get the sections
          //via its associated volume
          var volume = voxelLayer.SelectedVariableProfile.Volume;
    
          //get the selected section
          var section = MapView.Active.GetSelectedSections().FirstOrDefault();
          if (section == null)
    {
              //At 2.x - section = voxelLayer.GetSections().FirstOrDefault();
              section = volume.GetSections().FirstOrDefault();
          }
    
          if (section == null)
              return;
    
          //Lock the section (Creates a locked section, deletes
          //the section)
          //if (voxelLayer.CanLockSection(section))
          //    voxelLayer.LockSection(section);
          if (volume.CanLockSection(section))
              volume.LockSection(section);
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also