EditOperation IsEmpty after attribute change

220
2
Jump to solution
12-06-2023 08:32 AM
DaveWilcox
New Contributor III

I'm calling this code from a button on a dockpane. The current attribute value is null and I am changing the value to a number, so there should be a change, but the modifyFeature Edit Operation is empty after the Modify. Any ideas on what might be causing this?

 

        public static void SetFieldInt(Map? map, string layerName, string fieldName, int value)
        {
            try
            {
                if (map is null) return;
                BasicFeatureLayer? featureLayer = (BasicFeatureLayer?)FindLayer(map, layerName);
                if (featureLayer is null)
                    return;
                else
                {
                    Selection selectedFeatures = featureLayer.GetSelection();
                    var modifyInspector = new Inspector();
                    using (RowCursor rowCursor = selectedFeatures.Search())
                    {
                        while (rowCursor.MoveNext())
                        {
                            if (rowCursor.Current is not Feature feature) return;
                            long oid = feature.GetObjectID();
                            if (feature != null)
                            {
                                object den = feature[2];
                            }
                            modifyInspector.Load(featureLayer, feature.GetObjectID());
                            var modifyFeature = new EditOperation
                            {
                                Name = "Modify a feature"
                            };
                            modifyInspector[fieldName] = value;
                            modifyFeature.Modify(modifyInspector);
                            if (!modifyFeature.IsEmpty)
                            {
                                var result = modifyFeature.Execute();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new SystemException((System.Reflection.MethodBase.GetCurrentMethod()!.Name ?? "Unknown") + ": " + ex.Message);
            }
        }

 

 

Thanks!

-  David Wilcox

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

What version of ArcGIS Pro do you use? We have reported bug to Esri for version 3.0. Fixed in 3.2, 3.1.4

BUG-000153875 for ArcGIS Pro SDK for .NET (esri.com)

View solution in original post

0 Kudos
2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

What version of ArcGIS Pro do you use? We have reported bug to Esri for version 3.0. Fixed in 3.2, 3.1.4

BUG-000153875 for ArcGIS Pro SDK for .NET (esri.com)

0 Kudos
DaveWilcox
New Contributor III

I was at 3.1.3. Upgrading to 3.2.0 fixed the problem. Thanks!

- Dave

0 Kudos