Hi,
I'm trying to get the StartPoint of a selected Polyline. So far, this is what I have:
I use an Inspector to get each selected feature, like this:
var selection = currentLayer.GetSelection();
IReadOnlyList<long> selectedOIDs = selection.GetObjectIDs(); //save the selected OBJECTIDs to a list.
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); //create the Inspector
Then I loop through each selected OBJECTID:
foreach (var oid in selectedOIDs)
{
insp.Load(currentLayer, oid); //use the current OBJECTID as you go through the loop of selected features
Polyline theLine = insp.Shape as Polyline; //This works
Segment theSegment = insp.Shape as Segment; //This will not cast....not quite sure what to do here
MapPoint startPoint = theSegment.StartPoint; //This is ultimately what I want to get at
}
Since a Segment has a .StartPoint property, I think I need to cast my Polyline into a Segment, I'm just not sure how to do it. Of course, I could be totally wrong.
Any advice on how to do this would be appreciated.
Brian,
A polyline is technically a multipart geometry so you cant directly cast to segment, you need to get part(n) of the polyline first. Take a look at the Multipart geometry class.
The other way to get the start point is through the first item in a point collection: