ArcObjects Library Reference  (Geometry)    

IGeometryBridge_ReplacePoints_Example

[C#]
public void ReplacePoints()
{
  int length = 10;
  IPoint[] pointArray = new IPoint[length];
  for (int i = 0; i < length; i++)
  {
    pointArray[i] = new PointClass();
    pointArray[i].PutCoords(i * 10, i * 10);
  }
  IPointCollection4 pointCollection = new MultipointClass();
  //add points to pointCollection 
  IGeometryBridge geometryBridge = new GeometryEnvironmentClass();
  geometryBridge.AddPoints(pointCollection, ref pointArray);
  PrintPointCollection(pointCollection, "PointCollection before replacing points");

  //create replacement point 
  IPoint point3 = new PointClass();
  point3.PutCoords(999, 999);
  IPoint point4 = new PointClass();
  point4.PutCoords(666, 666);
  IPoint point5 = new PointClass();
  point5.PutCoords(333, 333);
  IPoint[] replacementPointArray = new IPoint[3];
  replacementPointArray[0] = point3;
  replacementPointArray[1] = point4;
  replacementPointArray[2] = point5;
  geometryBridge.ReplacePoints(pointCollection, 2, 3, ref replacementPointArray);
  PrintPointCollection(pointCollection, "PointCollection after replacing points");
}
private void PrintPointCollection(IPointCollection4 pointCollection, String header)
{
  String report = "";
  for (int i = 0; i < pointCollection.PointCount; i++)
  {
    IPoint currentPoint = new PointClass();
    pointCollection.QueryPoint(i, currentPoint);
    report = report + "index = " + i + " ,X = " + currentPoint.X + " ,Y = " + currentPoint.Y + "\n";
  }
  System.Windows.Forms.MessageBox.Show(header + "\n" + report);
}

[Visual Basic 6.0, Visual Basic .NET, C++]
No example is available for Visual Basic 6.0, Visual Basic .NET, or C++. To view a C# example, click the Language Filter button Language Filter in the upper-left corner of the page.