<?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 Get start / end coordinates of selected line feature in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-start-end-coordinates-of-selected-line-feature/m-p/1056490#M6566</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I haven't a lot of C# experience, so my question might be on the dim side. However I will ask anyway.&amp;nbsp;&lt;/P&gt;&lt;P&gt;What would be the easiest way to go about checking if the first element of selected features in the map is a Polyline, and if yes; get the first and last coordinate in the coordinate array?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried both Map.GetSelection and MapView.GetFeatures, however I am struggling to understand the best way to access the specific features and specifically its coord-array.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All help would be dearly appreciated.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 May 2021 23:33:48 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-05-10T23:33:48Z</dc:date>
    <item>
      <title>Get start / end coordinates of selected line feature</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-start-end-coordinates-of-selected-line-feature/m-p/1056490#M6566</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I haven't a lot of C# experience, so my question might be on the dim side. However I will ask anyway.&amp;nbsp;&lt;/P&gt;&lt;P&gt;What would be the easiest way to go about checking if the first element of selected features in the map is a Polyline, and if yes; get the first and last coordinate in the coordinate array?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried both Map.GetSelection and MapView.GetFeatures, however I am struggling to understand the best way to access the specific features and specifically its coord-array.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All help would be dearly appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 23:33:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-start-end-coordinates-of-selected-line-feature/m-p/1056490#M6566</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-05-10T23:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Get start / end coordinates of selected line feature</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-start-end-coordinates-of-selected-line-feature/m-p/1056567#M6570</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;1. Select 'Map Tool' project template to create the add-in.&lt;/P&gt;&lt;P&gt;2. Changed the cursor as normal cursor&amp;nbsp;&lt;/P&gt;&lt;P&gt;in the constructor(),&lt;/P&gt;&lt;P&gt;public CaptureCoordinates()&lt;BR /&gt;{&lt;BR /&gt;IsSketchTool = true;&lt;BR /&gt;SketchType = SketchGeometryType.Point; //.Point;&lt;BR /&gt;//UseSnapping = true;&lt;BR /&gt;SketchOutputMode = SketchOutputMode.Screen;&lt;BR /&gt;var systemCursor = System.Windows.Input.Cursors.Arrow;&amp;nbsp;&lt;BR /&gt;Cursor = systemCursor;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;3. This will give us "onsketchcompleteasync" functionality. This will return the selected geometry as Geometry object.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; within this method, use&lt;/P&gt;&lt;P&gt;protected async override Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync(Geometry geometry)&lt;BR /&gt;{&lt;BR /&gt;long targetID=0;&lt;BR /&gt;string strTargetLayerName = null;&lt;BR /&gt;await QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;var sourceSelection = ActiveMapView.SelectFeatures(geometry, SelectionCombinationMethod.New);&lt;/P&gt;&lt;P&gt;foreach (KeyValuePair&amp;lt;BasicFeatureLayer, List&amp;lt;long&amp;gt;&amp;gt; eachSel in sourceSelection)&lt;BR /&gt;{&lt;BR /&gt;targetID = eachSel.Value[0];&lt;BR /&gt;strTargetLayerName = eachSel.Key.Name;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;var inspTargetInspector = new Inspector();&lt;/P&gt;&lt;P&gt;var selectedTargetFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection();&lt;BR /&gt;inspTargetInspector.Load(selectedTargetFeatures.Keys.First(), targetID);&lt;BR /&gt;if (inspTargetInspector.Shape.GeometryType == GeometryType.Polyline)&lt;BR /&gt;{&lt;BR /&gt;var objpolyline = inspTargetInspector.Shape as Polyline;&lt;/P&gt;&lt;P&gt;//Below logic will change based on the logic. For now, we are just printing X, Y coordinates of each point in the polyline.&lt;BR /&gt;for (int i = 0; i &amp;lt; objpolyline.PointCount; i++)&lt;BR /&gt;{&lt;BR /&gt;MessageBox.Show("Points are : " + objpolyline.Points[i].X.ToString() + " " +&lt;BR /&gt;objpolyline.Points[i].Y.ToString());&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;return true;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After running application --&amp;gt; click on the add-in --&amp;gt; select the feature which we want to get coordinates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope, This will help you to get started as a draft. I am sure we can tweak this code further.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Sreeni.&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 07:10:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-start-end-coordinates-of-selected-line-feature/m-p/1056567#M6570</guid>
      <dc:creator>SreenivasaRaoPigili</dc:creator>
      <dc:date>2021-05-11T07:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Get start / end coordinates of selected line feature</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-start-end-coordinates-of-selected-line-feature/m-p/1056597#M6572</link>
      <description>&lt;P&gt;This was exactly what I was looking for.&lt;/P&gt;&lt;P&gt;I added some logic to check if a line feature was already selected, and if so just use the selected line feature into the code you posted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 09:43:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-start-end-coordinates-of-selected-line-feature/m-p/1056597#M6572</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-05-11T09:43:31Z</dc:date>
    </item>
  </channel>
</rss>

