<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic StartPoint of Polyline in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/startpoint-of-polyline/m-p/851931#M4284</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to get the StartPoint of a selected Polyline.&amp;nbsp; So far, this is what I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;I use an Inspector to get each selected feature, like this:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var selection = currentLayer.GetSelection();&lt;BR /&gt; IReadOnlyList&amp;lt;long&amp;gt; selectedOIDs = selection.GetObjectIDs(); //save the selected OBJECTIDs to a list.&lt;/P&gt;&lt;P&gt;var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); //create the Inspector&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt; Then I loop through each selected OBJECTID:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; foreach (var oid in selectedOIDs)&lt;BR /&gt; {&lt;BR /&gt; insp.Load(currentLayer, oid); //use the current OBJECTID as you go through the loop of selected features&lt;BR /&gt; &lt;BR /&gt; Polyline theLine = insp.Shape as Polyline;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;//This works&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Segment theSegment = insp.Shape as Segment;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;//This will not cast....not quite sure what to do here&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MapPoint startPoint = theSegment.StartPoint;&amp;nbsp; &lt;STRONG&gt;&lt;EM&gt;//This is ultimately what I want to get at&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; Of course, I could be totally wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice on how to do this would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Nov 2017 15:08:04 GMT</pubDate>
    <dc:creator>BrianBulla</dc:creator>
    <dc:date>2017-11-20T15:08:04Z</dc:date>
    <item>
      <title>StartPoint of Polyline</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/startpoint-of-polyline/m-p/851931#M4284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to get the StartPoint of a selected Polyline.&amp;nbsp; So far, this is what I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;I use an Inspector to get each selected feature, like this:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var selection = currentLayer.GetSelection();&lt;BR /&gt; IReadOnlyList&amp;lt;long&amp;gt; selectedOIDs = selection.GetObjectIDs(); //save the selected OBJECTIDs to a list.&lt;/P&gt;&lt;P&gt;var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); //create the Inspector&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt; Then I loop through each selected OBJECTID:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; foreach (var oid in selectedOIDs)&lt;BR /&gt; {&lt;BR /&gt; insp.Load(currentLayer, oid); //use the current OBJECTID as you go through the loop of selected features&lt;BR /&gt; &lt;BR /&gt; Polyline theLine = insp.Shape as Polyline;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;//This works&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Segment theSegment = insp.Shape as Segment;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;//This will not cast....not quite sure what to do here&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MapPoint startPoint = theSegment.StartPoint;&amp;nbsp; &lt;STRONG&gt;&lt;EM&gt;//This is ultimately what I want to get at&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; Of course, I could be totally wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice on how to do this would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2017 15:08:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/startpoint-of-polyline/m-p/851931#M4284</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2017-11-20T15:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: StartPoint of Polyline</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/startpoint-of-polyline/m-p/851932#M4285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brian,&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other way to get the start point is through the first item in a point collection:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;//get the sketch as a point collection&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; pointCol &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Multipart&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;sketchGeom&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Points&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; firstPoint &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; pointCol&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:29:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/startpoint-of-polyline/m-p/851932#M4285</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T10:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: StartPoint of Polyline</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/startpoint-of-polyline/m-p/851933#M4286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sean,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, I eventually found a sample that broke my line down into segments, but I like your solution much better.&amp;nbsp; Two lines of code is always better than 10, especially when all I need is the first point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I had:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Polyline theLine = insp.Shape as Polyline;&lt;BR /&gt; ReadOnlyPartCollection polylineParts = theLine.Parts;&lt;BR /&gt; IEnumerator&amp;lt;ReadOnlySegmentCollection&amp;gt; segments = polylineParts.GetEnumerator();&lt;BR /&gt; segments.MoveNext();&lt;BR /&gt; ReadOnlySegmentCollection seg = segments.Current;&lt;/P&gt;&lt;P&gt;foreach (Segment s in seg)&lt;BR /&gt; {&lt;BR /&gt; intersectPoint = s.StartPoint;&lt;BR /&gt; break; //to get just the first point&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!!&amp;nbsp; This is what I ultimately went with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var pointCollection = ((Multipart)insp.Shape).Points;&lt;BR /&gt; MapPoint thePoint = pointCollection[0];&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2017 18:21:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/startpoint-of-polyline/m-p/851933#M4286</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2017-11-20T18:21:37Z</dc:date>
    </item>
  </channel>
</rss>

