ArcObjects Library Reference  (Geometry)    

IGeometryBridge_InsertPoints_Example

[C#]
public void InsertPoints()
{
  IPoint point1 = new PointClass();
  point1.PutCoords(10, 10);
  IPoint point2 = new PointClass();
  point2.PutCoords(20, 20);
  IPoint[] pointArray = new IPoint[2];
  pointArray[0] = point1;
  pointArray[1] = point2;
  IPointCollection4 pointCollection = new MultipointClass();
  //insert points to pointCollection starting at the given index
  IGeometryBridge geometryBridge = new GeometryEnvironmentClass();
  int index = 0;
  geometryBridge.InsertPoints(pointCollection, index, ref pointArray);
  PrintPointCollection(pointCollection, "Inserted at index " + index);

  //insert more points at a different index
  IPoint point3 = new PointClass();
  point3.PutCoords(30, 30);
  IPoint point4 = new PointClass();
  point4.PutCoords(40, 40);
  IPoint[] secondPointArray = new IPoint[2];
  secondPointArray[0] = point3;
  secondPointArray[1] = point4;
  int secondindex = 1;
  geometryBridge.InsertPoints(pointCollection, secondindex, ref secondPointArray);
  PrintPointCollection(pointCollection, "Inserted at index " + secondindex);
  
}
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.