Hi,
So the following code works in 2.8. Basically it works with the selected features, performs some calculations, and then updates a field on each selected feature. For some reason in 3.0, only one of the selected feature s gets updated. It goes like this:
//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");
Any ideas what might be going wrong? I have gone through all the "Migrate to Pro" steps, so I do not think that is an issue. The project compiles fine and will run in debug mode with no errors. It's just that the Edit Operation only seems to be editing the final selected feature that is processes.