<?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: Layer.getExent() Crashes Arcmap in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111855#M8717</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I can reproduce, I'll look into this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Jul 2012 17:59:30 GMT</pubDate>
    <dc:creator>JeffBarrette</dc:creator>
    <dc:date>2012-07-05T17:59:30Z</dc:date>
    <item>
      <title>Layer.getExent() Crashes Arcmap</title>
      <link>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111854#M8716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The following code will crash a Python interpreter, or crash the entire Arcmap app if run inside the python window or in a toolbox tool:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import os, sys, time import arcpy&amp;nbsp; def main(): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; #make a layer from scratch &amp;nbsp;&amp;nbsp;&amp;nbsp; tfc = 'c:/arcview/sf/forest/tract.shp' &amp;nbsp;&amp;nbsp;&amp;nbsp; strmap = '4301' &amp;nbsp;&amp;nbsp;&amp;nbsp; t = 'tracts' &amp;nbsp;&amp;nbsp;&amp;nbsp; df = arcpy.AddFieldDelimiters(tfc, 'MAP') &amp;nbsp;&amp;nbsp;&amp;nbsp; exp = df + " = '" + strmap + "'" &amp;nbsp;&amp;nbsp;&amp;nbsp; result = arcpy.MakeFeatureLayer_management(tfc, t, exp) &amp;nbsp;&amp;nbsp;&amp;nbsp; lyr = result.getOutput(0) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # or get a layer from a .lyr file with the same def query &amp;nbsp;&amp;nbsp;&amp;nbsp; lyrfile = 'c:/temp/tract.lyr'&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; lyr2 = arcpy.mapping.Layer(lyrfile) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; #either of the next 2 lines bombs python, or crashes Arcmap if inside app &amp;nbsp;&amp;nbsp;&amp;nbsp; ext = lyr.getExtent() &amp;nbsp;&amp;nbsp;&amp;nbsp; ext2 = lyr2.getExtent()&amp;nbsp; if __name__ == '__main__': &amp;nbsp;&amp;nbsp;&amp;nbsp; main() &lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is the definition query, since both layers work fine without it.&amp;nbsp; The query works, and GetCount returns 1 for each layer.&amp;nbsp; This is 10.1, XP SP3.&amp;nbsp; Any help would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jul 2012 18:56:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111854#M8716</guid>
      <dc:creator>MikeHunter</dc:creator>
      <dc:date>2012-07-04T18:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Layer.getExent() Crashes Arcmap</title>
      <link>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111855#M8717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I can reproduce, I'll look into this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jul 2012 17:59:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111855#M8717</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2012-07-05T17:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Layer.getExent() Crashes Arcmap</title>
      <link>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111856#M8718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you sir.&amp;nbsp; Let us know if you figure something out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jul 2012 22:11:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111856#M8718</guid>
      <dc:creator>MikeHunter</dc:creator>
      <dc:date>2012-07-05T22:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Layer.getExent() Crashes Arcmap</title>
      <link>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111857#M8719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is a bug (NIM082523) and will be addressed for 10.1 SP1.&amp;nbsp; Arcpy is fetching a wrong (null) display transformation from layers generated from GP tools.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A possible work around it to reference the layers from within a Map Document.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Covert LYR to lyrfile, add to ArcMap TOC and reference it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Use arcpy.mapping.ListLayers on the layer if it is automatically added to the TOC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for reporting this,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jul 2012 20:29:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111857#M8719</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2012-07-06T20:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Layer.getExent() Crashes Arcmap</title>
      <link>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111858#M8720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have had a similar issue using .getSelectedExtent() in Python 2.7.&amp;nbsp; It restarts the shell whenever I use this method.&amp;nbsp; Glad to see it is going to be fixed.&amp;nbsp; Hopefully soon!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Aug 2012 20:03:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111858#M8720</guid>
      <dc:creator>JeffreySchmidt</dc:creator>
      <dc:date>2012-08-01T20:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Layer.getExent() Crashes Arcmap</title>
      <link>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111859#M8721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This was fixed and will be made available with 10.1 SP1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Aug 2012 14:27:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111859#M8721</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2012-08-02T14:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Layer.getExent() Crashes Arcmap</title>
      <link>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111860#M8722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This was fixed and will be made available with 10.1 SP1.&lt;BR /&gt;&lt;BR /&gt;Jeff&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have SP1 for 10.1 and I still get errors when using the layers getExtent() method on a layer with a definition query. The script hangs and dies unless I bypass all layers with a definition query in them.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 03:35:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111860#M8722</guid>
      <dc:creator>Peter_von_Minden</dc:creator>
      <dc:date>2013-02-21T03:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Layer.getExent() Crashes Arcmap</title>
      <link>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111861#M8723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just tested this bug again using the original bug data and can NOT reproduce the problem using 10.1 SP1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Its possible you have a different situation.&amp;nbsp; Please provide more details including part of your script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2013 19:32:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111861#M8723</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2013-02-26T19:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Layer.getExent() Crashes Arcmap</title>
      <link>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111862#M8724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; I just tested this bug again using the original bug data and can NOT reproduce the problem using 10.1 SP1.&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;It's possible you have a different situation. Please provide more details including part of your script.&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;Jeff&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Jeff,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the code I was testing on:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

mxdFullPath = r"C:\temp\test_with_def.mxd"

mxd = arcpy.mapping.MapDocument(mxdFullPath)

for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.isFeatureLayer == True:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print lyr.name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LAYEREXTENT = lyr.getExtent()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print str(LAYEREXTENT)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my mxd (test_with_def.mxd) I have a series of definition queries. The above code seems to work for some of these layers with definition queries (eg: RDCLASS = 'National Highway' on a roads layer) but it falls over when it reaches a contours layer with this definition query:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="color: &amp;quot;#808080&amp;quot;; font-style: italic;"&gt;mod(ELEVATION,100)=0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error in PyScripter, when I reach the layer with this definition, is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="color: &amp;quot;#808080&amp;quot;; font-style: italic;"&gt;EOFError: [Errno 10054] An existing connection was forcibly closed by the remote host&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All the layers are Oracle SDE layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your thoughts on the matter would be most appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pete&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:42:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111862#M8724</guid>
      <dc:creator>Peter_von_Minden</dc:creator>
      <dc:date>2021-12-11T06:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Layer.getExent() Crashes Arcmap</title>
      <link>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111863#M8725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have SP1 for 10.1 and I still get errors when using the layers getExtent() method on a layer with a definition query. The script hangs and dies unless I bypass all layers with a definition query in them.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also have 10.1 with SP1, and am getting a python crash on layer.getExtent()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's a simplified version of my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Layers = arcpy.mapping.ListLayers(arcpy.mapping.MapDocument(A_mxd_path))
for layer in Layers:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'layer:', layer
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; extent = layer.getExtent() #crash here after printing some layers
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the output I get up to the time python crashes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
layer strippedrx_poly_check 
layer shapefile 
layer strippedrx_poly_vr 
layer Yield1 
layer Yield2 
layer Yield3 
layer Yield4 
layer Yield5 
layer Borders 
layer VIEWS_2 
layer VIEWS_2\Image mosaic 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:42:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111863#M8725</guid>
      <dc:creator>TomRutherford</dc:creator>
      <dc:date>2021-12-11T06:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Layer.getExent() Crashes Arcmap</title>
      <link>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111864#M8726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I can not reproduce using similar datasets.&amp;nbsp; Please report to support services so they can work with you in reproducing the issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Dec 2013 20:14:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-getexent-crashes-arcmap/m-p/111864#M8726</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2013-12-02T20:14:30Z</dc:date>
    </item>
  </channel>
</rss>

