ArcGIS Pro 3.6 API Reference Guide
ArcGIS.Core.Data.Analyst3D Namespace / TinEditor Class / StopEditing Method
Indicates whether edits should be committed to disk.

If saveEdits is false, the TIN will be returned to the state previous to this edit session. All edits will be undone.

If saveEdits is true, edits from this session will be committed to disk. The TIN must already exist on disk before using this option or else an exception is thrown, and all edits are lost. If the TIN is new and has yet to be saved to disk, Use SaveAs first, then call this method.

Example

In This Topic
    StopEditing Method
    In This Topic
    Terminates edit mode. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public bool StopEditing( 
       bool saveEdits
    )
    Public Function StopEditing( _
       ByVal saveEdits As Boolean _
    ) As Boolean

    Parameters

    saveEdits
    Indicates whether edits should be committed to disk.

    If saveEdits is false, the TIN will be returned to the state previous to this edit session. All edits will be undone.

    If saveEdits is true, edits from this session will be committed to disk. The TIN must already exist on disk before using this option or else an exception is thrown, and all edits are lost. If the TIN is new and has yet to be saved to disk, Use SaveAs first, then call this method.

    Return Value

    Returns true if the method succeeds and false otherwise.
    Exceptions
    ExceptionDescription
    This method must be called on the MCT. Use QueuedTask.Run.
    The editor is not in edit mode.
    The edits can't be saved because the tin doesn't exist on disk or is invalid.
    Example
    Create a new TIN and save edits
    // Create a new TIN 
    tinEditor = new TinEditor(envelope);
    tinEditor.AddMassPoints(points, 42, 13.7);
    
    // Since the TIN doesn't exist on disk, you can't call SaveEdits.
    // You must call SaveAs first.
    try
    {
      tinEditor.SaveEdits();
    }
    catch (TinException)
    {
      // Handle the exception
    }
    
    // Since the TIN doesn't exist on disk, you can't call StopEditing(true).
    // You must call SaveAs first.
    try
    {
      tinEditor.StopEditing(true);
    }
    catch (TinException)
    {
      // Handle the exception
    }
    
    // Now save the newly created TIN to disk
    tinEditor.SaveAs("C:\\Tin1", false);
    
    // Delete a node
    tinEditor.DeleteNode(7);
    
    // Since the TIN now exists on disk you can call SaveEdits
    tinEditor.SaveEdits();
    
    // Delete another node
    tinEditor.DeleteNode(11);
    
    // Since the TIN now exists on disk, you can call StopEditing(true).
    // The edits will be saved and the tin editor will be taken out of edit mode.
    tinEditor.StopEditing(true);
    bool isInEditMode = tinEditor.IsInEditMode; // isInEditMode = false
    
    // Now if you try to make an edit, an exception is thrown because the editor is not in edit mode.
    try
    {
      tinEditor.AddPointZ(pointZ, 0);
    }
    catch (TinException)
    {
      // Handle the exception
    }
    
    // Put the editor into edit mode.
    tinEditor.StartEditing();
    isInEditMode = tinEditor.IsInEditMode; // isInEditMode = true
    
    // Now you can add the point
    tinEditor.AddPointZ(pointZ, 0);
    
    // Oops, you didn't really want to add the point. You want to stop editing and discard the unsaved edits
    // since the last time the editor was put into edit mode. All previous saved edits remain.
    tinEditor.StopEditing(false);
    
    Edit an existing TIN
    // Create an instance of TinEditor from an existing TinDataset
    tinEditor = new TinEditor(tinDataset);
    int numNodes = tinDataset.GetNodeCount();  // numNodes = 10
    tinEditor.AddPointZ(pointZ, 7);
    
    // Calling SaveEdits modifies the existing TIN
    tinEditor.SaveEdits();
    numNodes = tinDataset.GetNodeCount();  // numNodes = 11
    
    // Adding twenty points
    tinEditor.AddMassPoints(points, 10, 112.5);
    
    // Calling SaveAs creates a new TIN on disk, and 
    // the tin editor points to the new TIN.
    string tinPath2 = "C:\\Tin2";
    tinEditor.SaveAs(tinPath2, true);
    
    tinEditor.StopEditing(true);
    TinDataset tinDataset2 = OpenTin(tinPath2); // See https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-3D-Analyst-Data#working-with-tin-data
    numNodes = tinDataset2.GetNodeCount(); // numNodes = 31
    
    // The edits still show up in the original TIN while it is in memory, but if you open it
    // again you will see that it only has the edits that were saved before SaveAs was called.
    numNodes = tinDataset.GetNodeCount(); // numNodes = 31
    
    tinDataset = OpenTin(tinPath);
    numNodes = tinDataset.GetNodeCount(); // numNodes = 11
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.5 or higher.
    See Also