ArcObjects Library Reference  (Geometry)    

IGeometryBridge_QuerySegments_Example

[C#]
public void QuerySegments()
{
  int length = 10;
  ISegment[] segmentArray = new ISegment[length];
  for (int i = 0; i < length; i++)
  {
    ILine line = new LineClass();
    IPoint fromPoint = new PointClass();
    fromPoint.PutCoords(i * 10, i * 10);
    IPoint toPoint = new PointClass();
    toPoint.PutCoords(i * 15, i * 15);
    line.PutCoords(fromPoint, toPoint);
    
    segmentArray[i] = line as ISegment;
  }
  ISegmentCollection segmentCollection = new PolylineClass();
  //adds Segments to segmentCollection
  IGeometryBridge geometryBridge = new GeometryEnvironmentClass();
  geometryBridge.AddSegments(segmentCollection, ref segmentArray);
  //prepare output
  int index = 0;
  ISegment[] outputSegmentArray = new ISegment[segmentCollection.SegmentCount - index];
  for (int i = 0; i < outputSegmentArray.Length; i++)
  {
    outputSegmentArray[i] = new LineClass();
  }
  //query
  geometryBridge.QuerySegments(segmentCollection, index, ref outputSegmentArray);
  String report = "";
  for (int i = 0; i < outputSegmentArray.Length; i++)
  {
    ISegment currentSegment = outputSegmentArray[i];
    ILine currentLine = currentSegment as ILine;
    report = report + "index = " + i + " , FromPoint X = " + currentLine.FromPoint.X + " , FromPoint Y = " + currentLine.FromPoint.X ;
    report = report + " , ToPoint X = " + currentLine.ToPoint.X + " , ToPoint Y = " + currentLine.ToPoint.X + "\n";
  }
  System.Windows.Forms.MessageBox.Show(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.