ArcObjects Library Reference  (Geometry)    

IGeometryBridge_SetPoints_Example

[C#]
public void SetPoints()
{
  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();
  //add points to pointCollection 
  IGeometryBridge geometryBridge = new GeometryEnvironmentClass();
 
  geometryBridge.AddPoints(pointCollection, ref pointArray);
  PrintPointCollection(pointCollection, "PointCollection before setting points");

  //set points  - overrides all existing points
  IPoint point3 = new PointClass();
  point3.PutCoords(30, 30);
  IPoint point4 = new PointClass();
  point4.PutCoords(40, 40);
  IPoint point5 = new PointClass();
  point5.PutCoords(50, 50);
  IPoint[] secondPointArray = new IPoint[3];
  secondPointArray[0] = point3;
  secondPointArray[1] = point4;
  secondPointArray[2] = point5;
  geometryBridge.SetPoints(pointCollection, ref secondPointArray);
  PrintPointCollection(pointCollection, "PointCollection after setting 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.