I want to create a simple IPolyline with having two IPoints. But getting error: 'Zero-Length polylines not allowed.'
Sample code is given below.
private void CreateNewFeature(IFeatureWorkspace pFeatureWorkspace,string sClassName, IPoint pPointFrom, IPoint pPointTo)
{
IFeature pFeatureNew = default(IFeature);
IPolyline pPolyLine = default(IPolyline);
IFeatureClass pFeatClass = default(IFeatureClass);
object pBefore, pAfter;
IPointCollection pPointCollection = new Polyline();
try
{
pFeatClass = pFeatureWorkspace.OpenFeatureClass(sClassName);
pPolyLine = new PolylineClass();
//pPolyLine.FromPoint = pPointFrom;
//pPolyLine.ToPoint = pPointTo;
pBefore = Type.Missing;
pAfter = Type.Missing;
pPointCollection.AddPoint(pPointFrom, ref pBefore, ref pAfter);
pPointCollection.AddPoint(pPointTo, ref pBefore, ref pAfter);
pFeatureNew = pFeatClass.CreateFeature();
pFeatureNew.Shape = (IGeometry)pPointCollection;
pFeatureNew.Store();
}
catch (Exception ex)
{
}
}
Please help me out, what am I missing here? Thanks in advance.