Buffer geometries using IBufferConstruction() and IBufferConstructionProps

1450
4
07-07-2010 05:53 PM
ChrisWheldon
New Contributor
Ladies and Gents

This is what I am briefly trying to do. Buffer polylines using IBufferConstruction and IBufferConstructionProperties because I want to obtain mitred (flat) ends to the buffers. I would also like to parse in a field value as the buffer distance. I have got so far as to use the ITopologicalOperator but I am really struggling with a link to the IEnumGeometry and IGeometryCollection in the code. I have got to a point where I don't know what's what anymore.

I have been calling the module from my ThisDocument module using a UI button and passing in the buffer distance using an inputbox.

I hope someone can help me continue on. I am doing this because my highest licence seat is Editor.

Thank you

Chris
New Zealand
0 Kudos
4 Replies
AlexanderGray
Occasional Contributor III
Have you tried calling createfeaturebuffer from within the loop where you insert the features.  I have always created a new featurebuffer for each individual feature I insert.
0 Kudos
ChrisWheldon
New Contributor
Hi Alexander

Thanks for replying. I have not tried what you suggest as yet. I am trying to get my selected features into a geometry collection at the moment so that I can enumerate through them and pass each feature as input into the IBufferConstruction. Theoretically easy enough.

Regards
Chris
0 Kudos
ChrisWheldon
New Contributor
Hi all

I nearly have my buffers using IBufferConstruction. Using the code attached I am able to place the records in the table but NOT see the associated geometries, and of course I don't know why. The offending code is in the Do Until loop where I take the enumerated feature and try to pass this, with a buffer distance into the bufferconstruction method. I'm not sure if my use of the GeometryCollection output is correct. Using ITopologicalOperator works fine and is commented out because I wish to eventually get to IBufferConstructionProps.

Appreciate any help. I just need someone to see what I'm not.

Thanks

Chris
0 Kudos
ChrisWheldon
New Contributor
Hi

Can anyone out there see why I am getting records in the table but no geometries to match ?

Do Until pFeature Is Nothing

        Application.StatusBar.Message(0) = "Buffering " & l & " of " & d
        Set inputPolyline = pFeature.ShapeCopy

        'Set inputPolyline = pFeature.ShapeCopy
        Set pGeomColl = New GeometryBag
        pGeomColl.AddGeometry inputPolyline
       
        Set pEnumGeometry = pGeomColl
        pEnumGeometry.Reset
        'MsgBox "Geometry Count: " & pGeomColl.GeometryCount
        Set pGeo = pEnumGeometry.Next
        i = 1
        While Not pGeo Is Nothing
            'MsgBox "Geometry: " & i & " Geometry type: " & pGeo.GeometryType
           
            Dim pBC As IBufferConstruction
            Set pBC = New BufferConstruction
           
            'Dim pPolygon As IPolygon
            'Set pPolygon = pBC.Buffer(pGeo, dDist)
           
            Set pOutGeomColl = New GeometryBag
           
            Dim pOutPoly As IPolygon
            Set pOutPoly = New Polygon
           
            pOutGeomColl.AddGeometry pOutPoly
           
            pBC.ConstructBuffers pEnumGeometry, dDist, pOutGeomColl
           
            Set pNewFeature = pInsertFeatureBuffer
            Set pNewFeature.Shape = pOutPoly
            q = pInsertFeatureCursor.InsertFeature(pInsertFeatureBuffer) 'Insert the feature into the feature cursor
           
            i = i + 1
            Set pGeo = pEnumGeometry.Next
        Wend
       
        Set pFeature = pFeatureCursor.NextFeature
        l = l + 1
    Loop

Thanks
Chris
0 Kudos