Arcgis pro SDK 2.9.x Order RowChangedEvent

843
5
01-31-2023 03:07 AM
Labels (3)
QuintoGIS
New Contributor

Hello everybody, is it possible to understand in which order the editing events are triggered on a group of edited Featureclasses \ Table ? In this example I have 4 featureclasses called A,B,C and Z.

 

QuintoGIS_0-1675162752208.png

 

To register the change events I used the following code (taking the layers in toc order).

 

 

   protected override void OnClick()
        {

             QueuedTask.Run(() =>
             {
                 //Listen for row events on a layer
                 IEnumerable<FeatureLayer> layers = MapView.Active.Map.GetLayersAsFlattenedList().Where(layer => layer is FeatureLayer).Select(x=>(FeatureLayer)x);


                 if (lst.Count == 0)
                 {

                     foreach (var fl in layers)
                     {
                         try
                         {

                             var fc = fl.GetFeatureClass();
                             //These events are fired once ~per feature~,
                             //per table
                             SubscriptionToken rowCreateToken = RowChangedEvent.Subscribe(OnRowChanged, fc);
                             lst.Add(rowCreateToken);


                         }
                         catch (Exception e)
                         {

                         }

                     }

                 }
                 else
                 {
                     lst.ForEach(x => RowChangedEvent.Unsubscribe(x));
                     lst.Clear();
                 }

                 
                             

                 //subscribe to row events
                 
                // var rowDeleteToken = RowDeletedEvent.Subscribe(OnRowDeleted, layerTable);
             });
           

        }

        private Guid _currentRowChangedGuid = Guid.Empty;
        private void OnRowChanged(RowChangedEventArgs args)
        {
            try
            {
                Debug.WriteLine(args.Row.GetTable().GetName().Split('.')[1]);
                return;
			}catch(Exception e){
				return;
			}
		}

 

 

 

 

 

 

I take a group of features belonging to A,B,C and Z and move them (using the move tool). The return order of the modified features does not follow the registration, but it would appear to be a random order ( in this case Z,C,B,A). How is the return order of these events defined?

 

0 Kudos
5 Replies
CharlesMacleod
Esri Regular Contributor

as all features have the same edit being applied (a "move") i suspect that it has more to do with the order in which the features are ordered in the selection set. So the first feature in the selection set is probably moved first, the second moved second, etc. I dont think the order in which u register for events has any bearing on the order in which u receive the events.

 

0 Kudos
QuintoGIS
New Contributor

hi charles,

 

I did several tests and I don't think that the selection order affects the return order of the elements. In the tests I selected in the order: z,c,a,b and the answer order was: z,c,b,a. Another try with c,a,z,b -> z,c,b,a. I can not understand...

0 Kudos
CharlesMacleod
Esri Regular Contributor

the order in the selection set is controlled by object id I believe and not the order in which features are selected.

0 Kudos
QuintoGIS
New Contributor

I tried with objectid. The 4 Featureclasses have 5 objects in total

A -> objectid 104
B -> objectid 121
C -> objectid 103
Z -> objectid 61,200

When I move 104,121,103 and 61 the order is this : Z,C,B,A

The same with : 104,121,103 and 200

I'm even more confused 😞

0 Kudos
QuintoGIS
New Contributor

Any other idea?

0 Kudos