ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Snapping Class / SetSnapModes Method
a collection of SnapMode parameters
Example

In This Topic
    SetSnapModes Method (Snapping)
    In This Topic

    Sets the given snapping modes.

    Syntax
    Public Shared Sub SetSnapModes( _
       ByVal modes As IEnumerable(Of SnapMode) _
    ) 
    public static void SetSnapModes( 
       IEnumerable<SnapMode> modes
    )

    Parameters

    modes
    a collection of SnapMode parameters
    Remarks
    This method disables the current snapping modes and enables the given snapping modes. It is intended to efficiently set one or more snapping modes.
    Example
    Configure Snapping - Application SnapModes
    // set only Point and Edge snapping modes, clear everything else
    Snapping.SetSnapModes(
      new List<SnapMode>() { SnapMode.Point, SnapMode.Edge });
    
    // clear all snap modes
    Snapping.SetSnapModes(null);
    
    // set snap modes one at a time
    Snapping.SetSnapMode(SnapMode.Edge, true);
    Snapping.SetSnapMode(SnapMode.End, true);
    Snapping.SetSnapMode(SnapMode.Intersection, true);
    
    // get current snap modes
    var snapModes = Snapping.SnapModes;
    
    // get state of a specific snap mode
    bool isOn = Snapping.GetSnapMode(SnapMode.Vertex);
    Configure Snapping - Combined Example
    // interested in only snapping to the vertices of a specific layer of interest and not the vertices of other layers
    //  all other snapModes should be off.
    
    // snapping must be on
    Snapping.IsEnabled = true;
    
    // turn all application snapModes off
    Snapping.SetSnapModes(null);
    
    // set application snapMode vertex on 
    Snapping.SetSnapMode(SnapMode.Vertex, true);
    
    // ensure layer snapping is on
    await QueuedTask.Run(() =>
    {
      featureLayer.SetSnappable(true);
    });
    
    // set vertex snapping only
    var vertexOnly = new LayerSnapModes(false) { Vertex = true };
    
    // set vertex only for the specific layer, clearing all others
    var dict = new Dictionary<Layer, LayerSnapModes>();
    dict.Add(featureLayer, vertexOnly);
    Snapping.SetLayerSnapModes(dict, true);  // true = reset other layers
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also