ArcObjects Library Reference  (Geometry)    

IGeometryBridge_InsertWKSPointZs_Example

[C#]
public void InsertWKSPointZs()
{
  int length = 10;
  WKSPointZ[] pointArray = new WKSPointZ[length];
  for (int i = 0; i < length; i++)
  {
    pointArray[i] = new WKSPointZ();
    pointArray[i].X = i * 10;
    pointArray[i].Y = i * 10;
    pointArray[i].Z = i * 10;
  }
  IPointCollection4 pointCollection = new MultipointClass();
  //add points to pointCollection 
  IGeometryBridge geometryBridge = new GeometryEnvironmentClass();
  geometryBridge.AddWKSPointZs(pointCollection, ref pointArray);
  PrintWKSPointZCollection(pointCollection, "PointCollection before inserting points");

  //insert points
  int secondArrayLength = 5;
  WKSPointZ[] secondPointArray = new WKSPointZ[secondArrayLength];
  for (int i = 0; i < secondArrayLength; i++)
  {
    secondPointArray[i] = new WKSPointZ();
    secondPointArray[i].X = i * 33;
    secondPointArray[i].Y = i * 33;
    secondPointArray[i].Z = i * 33;
  }
  int index = 3;
  geometryBridge.InsertWKSPointZs(pointCollection, index, ref secondPointArray);
  PrintWKSPointZCollection(pointCollection, "PointCollection after inserting points");
  
}
private void PrintWKSPointZCollection(IPointCollection4 pointCollection, String header)
  {
    int index = 0;
    WKSPointZ[] pointArray = new WKSPointZ[pointCollection.PointCount-index];
    for (int i = 0; i < pointArray.Length; i++)
    {
      pointArray[i] = new WKSPointZ();
    }
    IGeometryBridge geometryBridge = new GeometryEnvironmentClass();
    geometryBridge.QueryWKSPointZs(pointCollection, index, ref pointArray);
    String report = "";
    for (int i = 0; i < pointArray.Length; i++)
    {
      WKSPointZ currentPoint = pointArray[i];
      report = report + "index = " + i + " ,X = " + currentPoint.X + " ,Y = " + currentPoint.Y + " ,Z = " + currentPoint.Z + "\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.