ArcObjects Library Reference  (Geometry)    

IGeometryBridge_ConstructBuffers_Example

[C#]
private void ConstructBuffers()
{
  //get first selected Feature from map
  IMxDocument mxDocument = m_application.Document as IMxDocument;
  IMap map = mxDocument.FocusMap;
  IEnumFeature featureEnumerator = map.FeatureSelection as IEnumFeature;
  featureEnumerator.Reset();
  IFeature currentFeature = featureEnumerator.Next();
  //loop over all selected features skipped
  if(currentFeature == null)
  {
    System.Windows.Forms.MessageBox.Show("Please select a feature");
    return;
  }
  
  ITopologicalOperator2 topologicalOperator = currentFeature.Shape as ITopologicalOperator2;
  if (topologicalOperator == null)
  {
    //this happens if the current feature is a Point
    return;
  }
  IGeometryBridge geometryBridge = new GeometryEnvironmentClass();
  double[] distanceArray = new double[10];
  for (int i = 0; i < distanceArray.Length; i++)
  {
    distanceArray[i] = i + 10;
  }
  IEnumGeometry geometryCollection = geometryBridge.ConstructBuffers(topologicalOperator, ref distanceArray);
  //loop over the geometry collection
  geometryCollection.Reset();
  //because we are construction buffers, the geometrytype is Polygon
  IPolygon polygon = geometryCollection.Next() as IPolygon;
  int counter = 1;
  while (polygon != null)
  {
    
    System.Windows.Forms.MessageBox.Show("Buffer length = " +polygon.Length);
    polygon = geometryCollection.Next() as IPolygon;
    counter++;
  }
}

[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.