<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: EditOperation in 3.0 not working as expected in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1262176#M9472</link>
    <description>&lt;P&gt;Hi Charles,&lt;/P&gt;&lt;P&gt;Thanks, I will give that a go, but do you know if there is something specific to 3.0 that might be the issue?&amp;nbsp; This exact same code has been working in 2.8 for years.&amp;nbsp; I use this same looping/EditOperation strategy in many of my tools I've created for 2.8 and never had any issues.&lt;/P&gt;&lt;P&gt;This is the first tool I am converting to 3.0 and I'm only now seeing issues.&amp;nbsp; I haven't seen anything online about EditOperation working differently in 3.0.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Feb 2023 21:56:45 GMT</pubDate>
    <dc:creator>BrianBulla</dc:creator>
    <dc:date>2023-02-27T21:56:45Z</dc:date>
    <item>
      <title>EditOperation in 3.0 not working as expected</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1262102#M9468</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;So the following code works in 2.8.&amp;nbsp; Basically it works with the selected features, performs some calculations, and then updates a field on each selected feature.&amp;nbsp; For some reason in 3.0, only one of the selected feature s gets updated.&amp;nbsp; It goes like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//Create an Inspector to edit the selected features
                        var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();

                        //Loop through each selected OID
                        foreach (var oid in selectedOIDs)
                        {
                            insp.Load(gravitySewerLayer, oid);

                            fromMHElevation = 0;
                            toMHElevation = 0;
                            
                            //Check if the feature has NULL for either invert.  If so, skip and go to next.
                            if ((insp["UPSTREAMINVERT"].Equals(System.DBNull.Value)) || (insp["DOWNSTREAMINVERT"].Equals(System.DBNull.Value)))
                            {
                                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(insp["FACILITYID"].ToString() + "  is missing required invert information.", "Error");
                            }
                            else
                            {
                                //Get the To and From point of the currently selected feature
                                var pointCollection = ((Multipart)insp.Shape).Points;
                                MapPoint fromPoint = pointCollection[0];
                                MapPoint toPoint = pointCollection[pointCollection.Count - 1];

                                //check to make sure the mahole ELEVATION has a value before proceeding

                                if ((GetIntersectingFeature(fromPoint, sanManholeLayer, "ELEVATION") == null) || (GetIntersectingFeature(toPoint, sanManholeLayer, "ELEVATION") == null))
                                {
                                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(insp["FACILITYID"] + " has no intersecting TO/FROM Manhole, or the TO/FROM Manhole has a NULL 'ELEVATION' value.", "No Manhole data found");
                                }
                                else
                                {
                                    //Find the ELEVATION of both manholes that intersects the ends of the gravity main                                
                                    double fromMHELevation = Convert.ToDouble(GetIntersectingFeature(fromPoint, sanManholeLayer, "ELEVATION"));
                                    double toMHELevation = Convert.ToDouble(GetIntersectingFeature(toPoint, sanManholeLayer, "ELEVATION"));

                                    avgDepth = ((toMHELevation + fromMHELevation) / 2) - ((Convert.ToDouble(insp["UPSTREAMINVERT"].ToString()) + Convert.ToDouble(insp["DOWNSTREAMINVERT"].ToString())) / 2);

                                    insp["EST_AVG_DEPTH"] = avgDepth;
                                    editOperation.Modify(insp);
                                    updatedFeatures++;
                                }
                            }

                        }

                        if (editOperation.Execute() == true)
                            ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(updatedFeatures.ToString() + " features updated.", "Sani. Avg. Depth Tool - Update Complete");
                        else
                            ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(editOperation.ErrorMessage.ToString() + "\n" + "\n" + "Please try again using the current selection.  If the problem persists, let Brian know.", "Sani. Avg. Depth Tool - ERROR");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas what might be going wrong?&amp;nbsp; I have gone through all the "Migrate to Pro" steps, so I do not think that is an issue.&amp;nbsp; The project compiles fine and will run in debug mode with no errors.&amp;nbsp; It's just that the Edit Operation only seems to be editing the final selected feature that is processes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 19:38:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1262102#M9468</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2023-02-27T19:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: EditOperation in 3.0 not working as expected</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1262166#M9471</link>
      <description>&lt;P&gt;i suspect it is because u hv one inspector that u r loading/reloading in the loop. Try passing the attributes inside a dictionary to the modify instead....something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//use attribute dictionary
var dict_attrib = new Dictionary&amp;lt;string, object&amp;gt;();
dict_attrib["EST_AVG_DEPTH"] = insp["EST_AVG_DEPTH"];
editOp.Modify(gravitySewerLayer, oid, dict_attrib);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[assuming Modify makes a copy of your dictionary when u call it....which i think it does....otherwise the "new" has to go outside the loop and u wld hv to hang on to the dict reference(s).....e.g. var list_dict = new List&amp;lt;Dictionary&amp;lt;string,object&amp;gt;&amp;gt;();]&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 21:53:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1262166#M9471</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2023-02-27T21:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: EditOperation in 3.0 not working as expected</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1262176#M9472</link>
      <description>&lt;P&gt;Hi Charles,&lt;/P&gt;&lt;P&gt;Thanks, I will give that a go, but do you know if there is something specific to 3.0 that might be the issue?&amp;nbsp; This exact same code has been working in 2.8 for years.&amp;nbsp; I use this same looping/EditOperation strategy in many of my tools I've created for 2.8 and never had any issues.&lt;/P&gt;&lt;P&gt;This is the first tool I am converting to 3.0 and I'm only now seeing issues.&amp;nbsp; I haven't seen anything online about EditOperation working differently in 3.0.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 21:56:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1262176#M9472</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2023-02-27T21:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: EditOperation in 3.0 not working as expected</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1262181#M9473</link>
      <description>&lt;P&gt;right, no, sorry, i don't. could be that at 2.x the internals were likewise making a copy of the (internal) inspector attribute collection in the Modify call but are now just holding a reference (as an optimization of sorts)....that's a guess just based on the change in behavior u r seeing tho.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 22:01:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1262181#M9473</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2023-02-27T22:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: EditOperation in 3.0 not working as expected</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1262343#M9475</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We have reported case to Esri support about the same behavior. It has bug status (BUG-000153876)&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 07:41:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1262343#M9475</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2023-02-28T07:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: EditOperation in 3.0 not working as expected</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1295447#M9910</link>
      <description>&lt;P&gt;Hi....just wondering if there is a fix for this yet in 3.0.....or even in 3.1??&amp;nbsp; I only have access to 3.0 currently.&lt;/P&gt;&lt;P&gt;I am converting another tool from 2.9 to 3.0, but having issues with the EditOperation working, again using the .Modify:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;await QueuedTask.Run(() =&amp;gt;
                {
                    Map map = MapView.Active.Map;

                    //Create the MAIN edit operation....this will show up on the Undo Stack
                    var editOperation = new ArcGIS.Desktop.Editing.EditOperation();
                    editOperation.Name = "Multi-Layer Attribute Update Tool";
                    editOperation.EditOperationType = ArcGIS.Desktop.Editing.EditOperationType.Long;

                    var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector();

                    //Go through each layer in the Layers listbox
                    foreach (string layer in lstLayers.Items)
                    {
                        var currentLayer = map.FindLayers(layer).FirstOrDefault() as BasicFeatureLayer;
                        var selection = currentLayer.GetSelection();
                        IReadOnlyList&amp;lt;long&amp;gt; selectedOIDs = selection.GetObjectIDs();

                        inspector.Clear();
                        inspector.Load(currentLayer, selectedOIDs);

                        foreach (var finalListRow in finalList)
                        {
                            if (finalListRow.FieldValue != null)
                                inspector[finalListRow.FieldName.ToString()] = finalListRow.FieldValue.ToString();
                        }

                        editOperation.Modify(inspector);
                    }

                    //Finished the layer loop....commit all the edits
                    if (!editOperation.IsEmpty)
                    {
                        bool result = editOperation.Execute();
                        if (!result)
                            MessageBox.Show("ERROR");
                    }
                });  //end of QueuedTask&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 17:46:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1295447#M9910</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2023-06-02T17:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: EditOperation in 3.0 not working as expected</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1295479#M9911</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Link shows status of the bug:&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en-us/bug/using-inspectorloadfeaturelayer-oid-to-update-one-featu-bug-000153876" target="_self"&gt;https://support.esri.com/en-us/bug/using-inspectorloadfeaturelayer-oid-to-update-one-featu-bug-000153876&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 18:41:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1295479#M9911</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2023-06-02T18:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: EditOperation in 3.0 not working as expected</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1297242#M9920</link>
      <description>&lt;P&gt;Thanks for posting a link to the bug.&amp;nbsp; So, with most of my editing tools, I follow the same process, and so far with my code upgrade to 3.0, none of them have worked.&amp;nbsp; But today I updgraded one and it actually did work.&amp;nbsp; The only difference was that it only edited geometry on each feature....no attribute editing.&amp;nbsp; Hopefully the bug fix above will solve the problems.&lt;/P&gt;&lt;P&gt;This code here, using .Modify, seems to be working in 3.0 for all selected features it's run on.&amp;nbsp; But only editing geometry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// start the EditOperation
                var modifyAsBuilts = new EditOperation();
                modifyAsBuilts.Name = "Move As-Builts and Site Plans";

                // Get any selected OIDs for the layer, and move each point to the mouse click point (geometry).
                if (asBuiltLayer != null)
                {
                    var selectedAB = asBuiltLayer.GetSelection();
                    IReadOnlyList&amp;lt;long&amp;gt; selectedAsbuiltOIDs = selectedAB.GetObjectIDs();

                    foreach (var oid in selectedAsbuiltOIDs)
                    {                        
                        modifyAsBuilts.Modify(asBuiltLayer, oid, geometry);
                        abCount++;
                    }
                }

// End the edit operation - move the selected As-Built and/or Site Plan points
                modifyAsBuilts.Execute();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 17:22:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1297242#M9920</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2023-06-08T17:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: EditOperation in 3.0 not working as expected</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1412473#M11393</link>
      <description>&lt;P&gt;After finally getting back to this, I can confirm that the BUG fix for this is working.....yeah!!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 18:43:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/editoperation-in-3-0-not-working-as-expected/m-p/1412473#M11393</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2024-04-19T18:43:58Z</dc:date>
    </item>
  </channel>
</rss>

