AnsweredAssumed Answered

StartPoint of Polyline

Question asked by bulla_b on Nov 20, 2017
Latest reply on Nov 20, 2017 by bulla_b


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.