1

I'm using C# to create ArcGIS Pro add-ins.

Until now I've been able to catch changes made directly on the attribute table. This is modify, create or remove a row. But, when I use a geoprocessing tool like 'Calculate Field", my code won't catch this change.

This is my script now:

using ArcGIS.Core.Data;
using ArcGIS.Core.Events;
using ArcGIS.Desktop.Editing;
using ArcGIS.Desktop.Editing.Attributes;
using ArcGIS.Desktop.Editing.Events;
using ArcGIS.Desktop.Framework.Contracts;
using ArcGIS.Desktop.Framework.Dialogs;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Mapping;
using System;
using System.Collections.Generic;
using System.Linq;

namespace AddinsArcGISPro
{    
    internal class MonitoringButton: Button
    {    
        private static SubscriptionToken _rowChangedToken;

        protected override void OnClick()
        {
            var featureLayer = MapView.Active.Map.Layers.First(t => t.Name == "TableName") as FeatureLayer;

            QueuedTask.Run(() => 
            {
                _rowChangedToken = RowChangedEvent.Subscribe(OnRowChangedEvent, featureLayer.GetTable());
            });
        }

        private static void OnRowChangedEvent(RowChangedEventArgs obj)
        {
            // Do something
        }
    }
}

What should I do to catch those changes made by geoprocessing tools?

  • 1
    I've yet to do any ArcPro development, all mine is in ArcMap. In ArcMap I can see why a geoprocessing tool is not picked up by an application user interface event as its not actually interacting with the application UI, it's processing at the dataset level. If you are trying to capture geoprocessing events may be you have to create some sort of flag which an extension picks up on? But I've no idea how that would work in ArcPro as my limited understanding is that it is an asynchronous environment? – Hornbydd Oct 29 '19 at 12:58
1

As @Hornbydd commented, the Geoprocessing environment is separate from the ArcGIS Pro UI. Similarly, it's not possible to undo anything you run from the Python command line in Pro.

I've actually exploited this to make underwater changes to datasets, that I don't want to interfere with my add-in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.