1

I want to create a line from two points in acrobjects. but i don't know how to save that line to a feature class

public static ILine CreateSegment(IPoint pFrom, IPoint pTo)
 {
    ILine line = new LineClass()
    line.PutCoords(pFrom,pTo)
    return line as ILine;
 }
5
  • 1
    What did you try so far? – Berend Aug 16 '17 at 6:52
  • actually i want to convert a polygon to polyline and i have done with creating points from the polygon now i have to make line from these points ... – vaibhav Dhiman Aug 16 '17 at 7:04
  • 1
    Ok, that's a different question. You may want to check out the IPointCollection interface on the polyline. It has an AddPointCollection method, which you can use to directly add the polygon's geometry. E.g. CType(polyline, IPointCollection).AddPointCollection(CType(polygon, IPointCollection)) – Berend Aug 16 '17 at 9:44
  • Please Edit the question in response to requests for clarification. It's not fair to those who would answer to need to mine the comments for critical information. – Vince Aug 16 '17 at 12:17
  • Have you considered ITopoligicalOperator.Boundary resources.arcgis.com/en/help/arcobjects-net/componenthelp/… or are you trying to get just the exterior ring(s) with no islands (holes)? – Michael Stimson Aug 23 '17 at 0:19
2

The sequence of steps is:

  1. Create a FeatureClass to store your features
  2. Create an insert cursor to insert features into your featureclass
  3. Create your line geometry
  4. Insert the new line

Keywords you need to be searching on the ArcObjects API help page are IFeature, IFeatureClass, IFeatureCursor

There are many code examples on the help page, here is just one to help you. Half the battle with ArcObjects is learning to navigate the help file.

1
  • One thing to be careful of, you can't store an ILine (implemented by ICurve which is implemented by IPath) in a feature class, you must store IPolyLine. Create an IGeometryCollection as PolyLine, add your ILine geometry then cast the IGeometryCollection to IGeometry, set the spatial reference on the IGeometry and then you can set the geometry (shape) of the IFeature or IFeatureBuffer for your insert cursor. I have a related answer which explains a bit about reading the help gis.stackexchange.com/questions/129456/… – Michael Stimson Aug 22 '17 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.