/// <summary> /// Normalizes all points in the selected subregion to the average elevation of the host surface. /// </summary> /// <param name="uiDoc">The document.</param> private void NormalizeSubregionAndPoints(UIDocument uiDoc) { Document doc = uiDoc.Document; // Pick subregion TopographySurface subregion = SiteUIUtils.PickSubregion(uiDoc); TopographySurface toposurface = SiteEditingUtils.GetTopographySurfaceHost(subregion); IList <XYZ> points = SiteEditingUtils.GetPointsFromSubregionExact(subregion); // Get elevation of all points on the toposurface IList <XYZ> allPoints = toposurface.GetPoints(); double elevation = SiteEditingUtils.GetAverageElevation(allPoints); // Edit scope for all changes using (TopographyEditScope editScope = new TopographyEditScope(doc, "Edit TS")) { editScope.Start(toposurface.Id); using (Transaction t = new Transaction(doc, "Normalize terrain")) { t.Start(); // Change all points to same elevation toposurface.ChangePointsElevation(points, elevation); t.Commit(); } editScope.Commit(new TopographyEditFailuresPreprocessor()); } }