<?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 Re: How to get the last element of a polyline array? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-get-the-last-element-of-a-polyline-array/m-p/408702#M32197</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I hadn't even thought of accessing the geometry object, focussed as I was with accessing the array. This will work nicely, thanks both!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Jul 2013 08:02:14 GMT</pubDate>
    <dc:creator>MennoNijhuis1</dc:creator>
    <dc:date>2013-07-02T08:02:14Z</dc:date>
    <item>
      <title>How to get the last element of a polyline array?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-last-element-of-a-polyline-array/m-p/408699#M32194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To my surprise, it is impossible to get the last element of an array from a polyline (which is a arcpy.arcobjects.arcobjects.Array, so not a normal Python array for which it would definitely work!). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;my_array[-1]&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;throws this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Runtime error &amp;lt;type 'exceptions.RuntimeError'&amp;gt;: Array: Error in getting object from array&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;OK a rather stupid workaround I thought of myself:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;my_array.getObject(len(my_array)-1)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;gives:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;lt;Point (280349.568, 311663.817, #, 162.393)&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;I still wonder: why is it not possible to just use my_array[-1]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 15:40:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-last-element-of-a-polyline-array/m-p/408699#M32194</guid>
      <dc:creator>MennoNijhuis1</dc:creator>
      <dc:date>2013-07-01T15:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the last element of a polyline array?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-last-element-of-a-polyline-array/m-p/408700#M32195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As you point out, an arcpy.arcobjects.arcobjects.Array is not a normal Python array,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;so it doesn't index nicely.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As a geometry object, however, it has a lastPoint property, which should be simple to access.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 18:09:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-last-element-of-a-polyline-array/m-p/408700#M32195</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2013-07-01T18:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the last element of a polyline array?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-last-element-of-a-polyline-array/m-p/408701#M32196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could subclass arcpy.Array to include a __getitem__ method, and then handle slicing and indexing there, if you want to be Pythonic about accessing the elements. However, Mark's solution is probably the simplest answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Shaun&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 18:49:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-last-element-of-a-polyline-array/m-p/408701#M32196</guid>
      <dc:creator>ShaunWalbridge</dc:creator>
      <dc:date>2013-07-01T18:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the last element of a polyline array?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-last-element-of-a-polyline-array/m-p/408702#M32197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I hadn't even thought of accessing the geometry object, focussed as I was with accessing the array. This will work nicely, thanks both!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 08:02:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-last-element-of-a-polyline-array/m-p/408702#M32197</guid>
      <dc:creator>MennoNijhuis1</dc:creator>
      <dc:date>2013-07-02T08:02:14Z</dc:date>
    </item>
  </channel>
</rss>

