.net arcgis pro sdk 2.3 inspector fails silently

588
3
Jump to solution
09-13-2019 08:56 AM
JibrahnKhoury
New Contributor II

Good afternoon,

 

We are developing .Net addins for Arcgis Pro 2.3, and have encountered an issue with the inspector. 

 

One of our addins is written to assign null value to an attribute for each feature in a layer. We've noticed that the attribute value is not always updated and it is unpredictable when it will fail. We have used both the inspector.Apply, ApplyAsync, and Edit Operation Modify. 

 

For example:

 

inspector["attr"] = DBNull.Value;

var successfulApply = inspector.Apply();

 

Even if successfulApply returns true, sometimes the assignment does not happen. Particularly when we run this on a large number of features. We usually test this by running the addin, and then checking the layer table, or checking individual feature attributes. 

 

For that simple addin, the developer runs the addin over and over until all features have a null value for that attribute. While that works eventually, it is slow and is not a viable option for all of our addins. 

 

Any ideas on how to approach this?

 

V/r,
Jibrahn Khoury

0 Kudos
1 Solution

Accepted Solutions
UmaHarano
Esri Regular Contributor

Hi Jibrahn

This issue was reported by another customer at 2.3 and has now been fixed in ArcGIS Pro 2.4 on wards.  I was able to test and confirm this.

Also, just as an FYI:

For faster performance, instead of making the edits to the attribute per row, you could load the Inspector with the map member and OIDs as explained in this snippet:  Load map selection into Inspector and Change Attributes

Thanks

Uma

View solution in original post

3 Replies
UmaHarano
Esri Regular Contributor

Hi Jibrahn 

If possible can you please send me a code sample and perhaps even a sample dataset so I can reproduce this? I can debug and see what is happening. You can attach zips to your post.

Thank you!

Uma

0 Kudos
JibrahnKhoury
New Contributor II

Hi Uma,

This is a short recreation (unfortunately the full code is running on another network)

private void SetNullAttribute()
{
   ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
   {
      using (RowCursor cursor = (OnlyCheckSelectedFeatures == true) ? layer.Layer.GetSelection().Search() :       layer.Layer.Search())
      {
         while (cursor.MoveNext())
         {
            using (Feature feature = (Feature)cursor.Current)
            {
               var line = feature.GetShape() as ArcGIS.Core.Geometry.Polyline;
               var inspector = new Inspector();
               inspector.Load(layer.Layer, line.GetObjectID());
               inspector["Attr1"] = DBNull.Value;
               bool attributeUpdated = inspector.Apply();

            }
         }
      }
   });
}

This is a method from the codebehind of a wpf window. The data is unavailable, but we are currently using a local .gdb file for testing.

If you have or can easily create a dummy dataset, ours is about 30,000 features. The attributes that we are setting are of type "Guid?".

This function will work most of the time, but occasionally it will not set a value, even if the return value of .Apply is true.

0 Kudos
UmaHarano
Esri Regular Contributor

Hi Jibrahn

This issue was reported by another customer at 2.3 and has now been fixed in ArcGIS Pro 2.4 on wards.  I was able to test and confirm this.

Also, just as an FYI:

For faster performance, instead of making the edits to the attribute per row, you could load the Inspector with the map member and OIDs as explained in this snippet:  Load map selection into Inspector and Change Attributes

Thanks

Uma