hsiddique

Help with buffering

Discussion created by hsiddique on Nov 9, 2011
Latest reply on Nov 10, 2011 by Neil
Hi all,

I've just started learning VBA and Arcobjects, and at the moment just playing around trying to do different things. What i am trying to do is Click on a tool, and allow the user to put a point graphic on the map, but also buffer the point(marker) that has been added. I can get the point on the map, but seem to be going round in circles getting the buffer to work. Can someone give me some hints ( i dont want the exact answer just some guidance on where I am going wrong.
Code is here.

Private Sub Buffer_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long) 
 
Dim pMxDoc As IMxDocument ' Create Object for current document 
Set pMxDoc = ThisDocument ' Set object to current Document 
 
Dim pMap As IMap ' Create object for current map 
Set pMap = pMxDoc.FocusMap ' Set object to the current active map 
 
Dim pPoint As IPoint 'Create object for point on map 
Set pPoint = pMxDoc.CurrentLocation '  Set object to current location 
 
Dim pElement As IElement ' Create object for graphic THAT IS ADDED TO THE MAP!!!! 
Set pElement = New MarkerElement ' Set object to a new marker element (point graphic) 
 
pElement.Geometry = pPoint ' Assign the geometry of the element to the Point. 
 
Dim pGraphics As IGraphicsContainer ' Create object to hold the graphic 
Set pGraphics = pMap ' Set object to current active map 
 
pGraphics.AddElement pElement, 0 '  Set the graphic that will be added 
 
Dim pActiveView As IActiveView ' Create object for active map display 
Set pActiveView = pMxDoc.ActiveView ' Set object to the Active view 
 
'--------------CREATE BUFFER------------------------' 
 
 Dim pSpaRef As ISpatialReference3 
 Set pSpaRef = pMap.SpatialReference 
 
 Dim pFCBuffer As IFeatureCursorBuffer2 ' Create Object for buffer 
 Set pFCBuffer = New FeatureCursorBuffer ' Set object for new buffer 
 
 pFCBuffer.Dissolve = True 
 pFCBuffer.ValueDistance = 100 
 Set pFCBuffer.BufferSpatialReference = pSpaRef 
 Set pFCBuffer.DataFrameSpatialReference = pSpaRef 
 Set pFCBuffer.SourceSpatialReference = pSpaRef 
 Set pFCBuffer.TargetSpatialReference = pSpaRef 
 
 
 Dim pCGLayer As ICompositeGraphicsLayer2 
 Set pCGLayer = New CompositeGraphicsLayer 
 
 Dim pGLayer As IGraphicsLayer 
 Set pGLayer = pMap.ActiveGraphicsLayer 
 
 
 pFCBuffer.BufferToGraphics pGLayer 
 
 
 
   pActiveView.PartialRefresh esriViewGraphics, pElement, Nothing ' [partial refresh of the graphics element. 
 
  End Sub 
 
 


Any advice ?

Halil

Outcomes