Add line feature to polyline feature class - VB/VBA

1015
2
04-14-2011 07:29 PM
WoodyFields
New Contributor
I am pulling my hair out on this one.  I have a polyline feature class and two points in a point shapefile.  I have the points set as IPoints in code.  I have the polyline set as an IPolyline.  I defined an IPath using the two IPoints as from and to points.  I have tried using the .AddGeometry function to add the two points as a path to my existing polyline layer with no luck.  Maybe I am not setting the feature class correctly to accept the geometry.  Maybe there is a better way?  Can someone please help me?

Thanks in advance!

Wood
0 Kudos
2 Replies
NeilClemmons
Regular Contributor III
You can only add high level geometries to feature classes.  A path isn't a high level geometry.  A line feature class can only store polyline geometries.  You need to be creating a new polyline geometry and using that to set the geometry of a new feature.

Dim polyline As IPolyline = new Polyline
polyline.FromPoint = onePoint
polyline.ToPoint = otherPoint
Dim feature As IFeature = featureClass.CreateFeature
feature.Shape = polyline
feature.Store
0 Kudos
WoodyFields
New Contributor
Thanks Neil!  That did the trick and fits into my code so much nicer.  Any way I can give you "he is awesome points" for this?
0 Kudos