Select to view content in your preferred language

Create IPolyline with two IPoints- 'Zero-Length polylines not allowed

2208
2
05-26-2013 10:08 PM
AlokMishra
New Contributor
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.
0 Kudos
2 Replies
deleted-user-VeC5jUIlNXtq
Deactivated User
Hi,

I think this might be better off in the ArcObjects SDK's forum.

Cheers,
0 Kudos