Buffering using VBA

Discussion created by rgangavalli on Oct 30, 2013
Latest reply on Nov 7, 2013 by rgangavalli
I am using the following code to draw a 1 mile buffer around a polygon. When I measure the distance from the edge of the polygon to the buffer, its not accurate. North and South are fine, but East and West are off.

Dim pMxDoc As IMxDocument
  Dim pActiveView As IActiveView
  Dim pGraphicsContainer As IGraphicsContainer
  Dim pEnumFeature As IEnumFeature
  Dim pFeature As IFeature
  Dim pTopoOp As ITopologicalOperator
  Dim pElement As IElement
  Dim strBufferDistance As String
  Set pMxDoc = Application.Document
  Set pActiveView = pMxDoc.FocusMap
  Set pGraphicsContainer = pMxDoc.FocusMap
  'Verify there is a feature selection
  If pMxDoc.FocusMap.SelectionCount = 0 Then Exit Sub
  'Get a buffer distance from the user
  strBufferDistance = InputBox("Enter Distance:", "Buffer")
  If strBufferDistance = "" Or Not IsNumeric(strBufferDistance) Then Exit Sub
  'Buffer all the selected features by the BufferDistance
  'and create a new polygon element from each result
  Set pEnumFeature = pMxDoc.FocusMap.FeatureSelection
  Set pFeature = pEnumFeature.Next
  Do While Not pFeature Is Nothing
    Set pTopoOp = pFeature.Shape
    Set pElement = New PolygonElement
    pElement.Geometry = pTopoOp.Buffer(CInt(strBufferDistance))
    pGraphicsContainer.AddElement pElement, 0
    Set pFeature = pEnumFeature.Next
  'Redraw the graphics