<?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: df.zoomToSelectedFeatures not working in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163030#M12491</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've solved it! &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The answer was adding another arcpy.MakeFeatureLayer_management () command after adding the layer to the mxd. Apparantly 'helkaelyr' was no longer a feature layer after adding it. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Plus some new paramaters and checks to make sure there was actually something being selected by the arcpy.SelectLayerByAttribute_management () command. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the new code, it works perfectly now:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Import the arcgisscripting module. import arcpy&amp;nbsp; # Setting the Variabls.&amp;nbsp; # Input gush and Helka. Gush = arcpy.GetParameterAsText(0) Helka = arcpy.GetParameterAsText(1)&amp;nbsp; # Output Location (the folder where the resualt will be saved). Workspace = arcpy.GetParameterAsText(2) arcpy.env.workspace = Workspace&amp;nbsp; # Exporting the wanted Helka: hel_openland_shp = r"W:\Av_data\CADASTER_2012-11-18\PARCEL_ALL.shp" Output_Layer = "hel_openland_Layer"&amp;nbsp; arcpy.MakeFeatureLayer_management(hel_openland_shp, Output_Layer)&amp;nbsp; arcpy.SelectLayerByAttribute_management(Output_Layer, "NEW_SELECTION", "\"GUSH_NUM\" = " + str(Gush))&amp;nbsp; arcpy.SelectLayerByAttribute_management(Output_Layer, "SUBSET_SELECTION", "\"PARCEL\" = " + str(Helka))&amp;nbsp; result = arcpy.CopyFeatures_management(Output_Layer, "Gush_" + str(Gush) + "_Helka_" + str(Helka)) helkafc = result.getOutput(0)&amp;nbsp; arcpy.SelectLayerByAttribute_management(Output_Layer, "CLEAR_SELECTION", "")&amp;nbsp; # Setting the Map file and the Data Frames: mxd = arcpy.mapping.MapDocument(r"E:\Local Disk (E)\users\Ilan\Projects\Python\Helkot_Maps_tool\MXDproject.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Parcel_Map") [0]&amp;nbsp; # Adding the wanted Helka to the first Data Frame: helka_layer = "Helka" + "_" + Helka&amp;nbsp; arcpy.MakeFeatureLayer_management(helkafc, helka_layer)&amp;nbsp; helkalyr = arcpy.mapping.Layer(helka_layer)&amp;nbsp; arcpy.mapping.AddLayer(df, helkalyr, "TOP")&amp;nbsp; # Setting the Scale for the Data Frame and applying symbology to the Helka:&amp;nbsp; lyr = arcpy.mapping.ListLayers(mxd, helkalyr.name, df)[0]&amp;nbsp; print lyr&amp;nbsp; arcpy.MakeFeatureLayer_management(helkalyr, lyr)&amp;nbsp; result1 = arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", "")&amp;nbsp; if int(arcpy.GetCount_management(lyr).getOutput(0)) &amp;gt; 0: &amp;nbsp;&amp;nbsp;&amp;nbsp; print result1.getOutput(0)&amp;nbsp; df.zoomToSelectedFeatures()&amp;nbsp; df.scale = 8000&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION", "")&amp;nbsp; inputLayer = arcpy.mapping.ListLayers(mxd, helkalyr.name, df)[0] symbologyLayer = arcpy.mapping.Layer("E:\\Local Disk (E)\\users\\Ilan\\Projects\\Python\\Helkot_Maps_tool\\wanted_layer.lyr")&amp;nbsp; arcpy.mapping.UpdateLayer(df, inputLayer, symbologyLayer, True)&amp;nbsp; # Changing text elements in the map to match the Gush and Helka: for textElement in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"): &amp;nbsp; if textElement.text == "map title": &amp;nbsp;&amp;nbsp;&amp;nbsp; textElement.text = "Gush" + " " + Gush + " " + "Helka" + " " + Helka&amp;nbsp; arcpy.RefreshActiveView()&amp;nbsp; # Exporting the Map file to a JPEG file: arcpy.mapping.ExportToJPEG(mxd, Workspace, df_export_width=640, df_export_height=480, resolution=150, &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; world_file=False, color_mode=1, jpeg_quality=100, progressive=False)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much for all the help! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Feb 2013 04:41:05 GMT</pubDate>
    <dc:creator>IlanGoichman</dc:creator>
    <dc:date>2013-02-26T04:41:05Z</dc:date>
    <item>
      <title>df.zoomToSelectedFeatures not working</title>
      <link>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163022#M12483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've writen a Python script which worked perfectly on v 10. now, when i have v 10.1, the script works good except for 1 part: df.zoomToSelectedFeatures. The script selects a parcel, copies it, adds it to an mxd, zooms to it (it's suppose to do it), changes its symbology, sets the df.scale and exports to JPEG file. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; #Import the arcgisscripting module.
import arcpy

# Setting the Variabls.

# Input gush and Helka.
Gush = 11516
Helka = 23

# Output Location (the folder where the resualt will be saved).
Workspace = r"E:\Local Disk (E)\users\Ilan\Projects\Helkot_Maps\11516_23"
arcpy.env.workspace = Workspace

# Exporting the wanted Helka:
hel_openland_shp = r"W:\Av_data\CADASTER_2012-11-18\PARCEL_ALL.shp"
Output_Layer = "hel_openland_Layer"

arcpy.MakeFeatureLayer_management(hel_openland_shp, Output_Layer)

arcpy.SelectLayerByAttribute_management(Output_Layer, "NEW_SELECTION", " \"GUSH_NUM\" = " + str(Gush))


arcpy.SelectLayerByAttribute_management(Output_Layer, "SUBSET_SELECTION", "\"PARCEL\" = " + str(Helka))

result = arcpy.CopyFeatures_management(Output_Layer, "Gush_" + str(Gush) + "_Helka_" + str(Helka))
helkafc = result.getOutput(0)

# Setting the Map file and the Data Frames:
mxd = arcpy.mapping.MapDocument("E:\\Local Disk (E)\\users\\Ilan\\Projects\\Python\\Helkot_Maps_tool\\MXDproject.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Parcel_Map") [0]

# Adding the wanted Helka to the first Data Frame:
helka_layer = "Helka" + " " + str(Helka)

arcpy.MakeFeatureLayer_management(helkafc, helka_layer)

helkalyr = arcpy.mapping.Layer(helka_layer)

arcpy.mapping.AddLayer(df, helkalyr, "TOP")

# Setting the Scale for the Data Frame and applying symbology to the Helka:

arcpy.SelectLayerByAttribute_management(str(helkalyr), "NEW_SELECTION", "\"PARCEL\" = 23")

df.zoomToSelectedFeatures()

arcpy.SelectLayerByAttribute_management(str(helkalyr), "CLEAR_SELECTION", "")

inputLayer = arcpy.mapping.ListLayers(mxd, helkalyr.name, df)[0]
symbologyLayer = arcpy.mapping.Layer("E:\\Local Disk (E)\\users\\Ilan\\Projects\\Python\\Helkot_Maps_tool\\wanted_layer.lyr")

arcpy.mapping.UpdateLayer(df, inputLayer, symbologyLayer, True)

df.scale = 8000

# Changing text elements in the map to match the Gush and Helka:
for textElement in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
&amp;nbsp; if textElement.text == "map title":
&amp;nbsp;&amp;nbsp;&amp;nbsp; textElement.text = "Gush" + " " + str(Gush) + " " + "Helka" + " " + str(Helka)

arcpy.RefreshActiveView()

# Exporting the Map file to a JPEG file:
arcpy.mapping.ExportToJPEG(mxd, Workspace, df_export_width=640, df_export_height=480, resolution=150,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; world_file=False, color_mode=1, jpeg_quality=100, progressive=False)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is only a trial example. the final one will have 'arcpy.GetParameterAsText(0)' for the Gush, Helka and workspace parameters. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I simply dont understand why the df.zoomToSelectedFeatures function doesnt work. i get a jpeg file with all the layers and the symbology, and the scale and the text changes, but without the zoom in to the selected features. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Will appriciate any help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:07:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163022#M12483</guid>
      <dc:creator>IlanGoichman</dc:creator>
      <dc:date>2021-12-12T16:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: df.zoomToSelectedFeatures not working</title>
      <link>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163023#M12484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You have this set to a static scale. Is this not the result you are getting?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;df.scale = 8000&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could also try isolating the layer to make sure there aren't any other selections.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;df.extent = lyr.getSelectedExtent()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2013 15:15:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163023#M12484</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-02-18T15:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: df.zoomToSelectedFeatures not working</title>
      <link>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163024#M12485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; You have this set to a static scale. Is this not the result you are getting?&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; &lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;df.scale = 8000&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;You could also try isolating the layer to make sure there aren't any other selections.&amp;nbsp; &lt;BR /&gt; &lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;df.extent = lyr.getSelectedExtent()&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The JPEg which the script generates is at 1:8000 scale, as specified in the script. But, the map isnt zoomd to the selected feature. It's fixed on another part, and i just dont understand why. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If i use 'df.extent = lyr.getSelectedExtent()' then the script crashes when it gets to that part and gives me an error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;exceprions:EOEError:[Errorno 10054] An existing connection was forcibly closed by remote host. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I realy have no idea why it's not working.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 10:56:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163024#M12485</guid>
      <dc:creator>IlanGoichman</dc:creator>
      <dc:date>2013-02-19T10:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: df.zoomToSelectedFeatures not working</title>
      <link>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163025#M12486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That error seems to indicate you are not selecting anything or your selection is not valid. Have you checked to see if you actually select anything using .getOuput() or .FIDSet? Have you tried doing this process manually in ArcMap?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 12:23:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163025#M12486</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-02-19T12:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: df.zoomToSelectedFeatures not working</title>
      <link>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163026#M12487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;That error seems to indicate you are not selecting anything or your selection is not valid. Have you checked to see if you actually select anything using .getOuput() or .FIDSet? Have you tried doing this process manually in ArcMap?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your help. i have added a line to the script to check if there is actually something being selected usint getOutput (), and then printing the result. I do get the name of the parcel, which means that it is being seleted. But still, df.zoomToSelectedFeatures is not working. The jpeg is still fixed on another part of the map and not on the selected parcel. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;can the be some other way of writing this is V 10.1? since its working in v 10? I cant think on anything else, but&amp;nbsp; im not that expirienced in Python.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Feb 2013 03:47:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163026#M12487</guid>
      <dc:creator>IlanGoichman</dc:creator>
      <dc:date>2013-02-25T03:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: df.zoomToSelectedFeatures not working</title>
      <link>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163027#M12488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thank you for your help. i have added a line to the script to check if there is actually something being selected usint getOutput (), and then printing the result. I do get the name of the parcel, which means that it is being seleted. But still, df.zoomToSelectedFeatures is not working. The jpeg is still fixed on another part of the map and not on the selected parcel. &lt;BR /&gt;&lt;BR /&gt;can the be some other way of writing this is V 10.1? since its working in v 10? I cant think on anything else, but&amp;nbsp; im not that expirienced in Python.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;About trying it manualy in Arcmap - the select by attribute tool works good, then the map zooms to the selcted feature when i pushe the 'zoom to selected featuresw button.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If i try the script in Python window, df.zoomToSelectedFeatures&amp;nbsp; still doesnt work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Feb 2013 04:05:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163027#M12488</guid>
      <dc:creator>IlanGoichman</dc:creator>
      <dc:date>2013-02-25T04:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: df.zoomToSelectedFeatures not working</title>
      <link>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163028#M12489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've solved it!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I deleted the df.zoomToSelectedFeatures line from the script. Apperantely, in V 10.1 there is an automatic zoom to the selected features, so no command is actually needed, only setting the scale after selection, and deselecting the feature. Other then that i have no other explanation for this.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my script, which is working perfectly now: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import the arcgisscripting module.
import arcpy

# Setting the Variabls.

# Input gush and Helka.
Gush = arcpy.GetParameterAsText(0)
Helka = arcpy.GetParameterAsText(1)

# Output Location (the folder where the resualt will be saved).
Workspace = arcpy.GetParameterAsText(2)
arcpy.env.workspace = Workspace

# Exporting the wanted Helka:
hel_openland_shp = r"W:\Av_data\CADASTER_2012-11-18\PARCEL_ALL.shp"
Output_Layer = "hel_openland_Layer"

arcpy.MakeFeatureLayer_management(hel_openland_shp, Output_Layer)

arcpy.SelectLayerByAttribute_management(Output_Layer, "NEW_SELECTION", "\"GUSH_NUM\" = " + Gush)

arcpy.SelectLayerByAttribute_management(Output_Layer, "SUBSET_SELECTION", "\"PARCEL\" = " + Helka)

result = arcpy.CopyFeatures_management(Output_Layer, "Gush_" + Gush + "_Helka_" + Helka)
helkafc = result.getOutput(0)

# Setting the Map file and the Data Frames:
mxd = arcpy.mapping.MapDocument(r"E:\Local Disk (E)\users\Ilan\Projects\Python\Helkot_Maps_tool\MXDproject.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Parcel_Map") [0]

# Adding the wanted Helka to the first Data Frame:
helka_layer = "Helka" + " " + Helka

arcpy.MakeFeatureLayer_management(helkafc, helka_layer)

helkalyr = arcpy.mapping.Layer(helka_layer)

arcpy.mapping.AddLayer(df, helkalyr, "TOP")

# Setting the Scale for the first Data Frame and applying symbology to the Helka:
result = arcpy.SelectLayerByAttribute_management(helkalyr, "NEW_SELECTION", "\"PARCEL\" = 23")

if int(arcpy.GetCount_management(helkalyr).getOutput(0)) &amp;gt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print result.getOutput(0)

df.scale = 8000

arcpy.SelectLayerByAttribute_management(helkalyr, "CLEAR_SELECTION", "")

inputLayer = arcpy.mapping.ListLayers(mxd, helkalyr.name, df)[0]
symbologyLayer = arcpy.mapping.Layer("E:\\Local Disk (E)\\users\\Ilan\\Projects\\Python\\Helkot_Maps_tool\\wanted_layer.lyr")

arcpy.mapping.UpdateLayer(df, inputLayer, symbologyLayer, True)

# Changing text elements in the map to match the Gush and Helka:
for textElement in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
&amp;nbsp; if textElement.text == "map title":
&amp;nbsp;&amp;nbsp;&amp;nbsp; textElement.text = "Gush" + " " + Gush + " " + "Helka" + " " + Helka

arcpy.RefreshActiveView()

# Exporting the Map file to a JPEG file:
arcpy.mapping.ExportToJPEG(mxd, Workspace, df_export_width=640, df_export_height=480, resolution=150,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; world_file=False, color_mode=1, jpeg_quality=100, progressive=False)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:33:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163028#M12489</guid>
      <dc:creator>IlanGoichman</dc:creator>
      <dc:date>2021-12-11T08:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: df.zoomToSelectedFeatures not working</title>
      <link>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163029#M12490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Did you try this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;df.extent = helkalyr.getSelectedExtent()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Feb 2013 12:15:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163029#M12490</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-02-25T12:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: df.zoomToSelectedFeatures not working</title>
      <link>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163030#M12491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've solved it! &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The answer was adding another arcpy.MakeFeatureLayer_management () command after adding the layer to the mxd. Apparantly 'helkaelyr' was no longer a feature layer after adding it. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Plus some new paramaters and checks to make sure there was actually something being selected by the arcpy.SelectLayerByAttribute_management () command. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the new code, it works perfectly now:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Import the arcgisscripting module. import arcpy&amp;nbsp; # Setting the Variabls.&amp;nbsp; # Input gush and Helka. Gush = arcpy.GetParameterAsText(0) Helka = arcpy.GetParameterAsText(1)&amp;nbsp; # Output Location (the folder where the resualt will be saved). Workspace = arcpy.GetParameterAsText(2) arcpy.env.workspace = Workspace&amp;nbsp; # Exporting the wanted Helka: hel_openland_shp = r"W:\Av_data\CADASTER_2012-11-18\PARCEL_ALL.shp" Output_Layer = "hel_openland_Layer"&amp;nbsp; arcpy.MakeFeatureLayer_management(hel_openland_shp, Output_Layer)&amp;nbsp; arcpy.SelectLayerByAttribute_management(Output_Layer, "NEW_SELECTION", "\"GUSH_NUM\" = " + str(Gush))&amp;nbsp; arcpy.SelectLayerByAttribute_management(Output_Layer, "SUBSET_SELECTION", "\"PARCEL\" = " + str(Helka))&amp;nbsp; result = arcpy.CopyFeatures_management(Output_Layer, "Gush_" + str(Gush) + "_Helka_" + str(Helka)) helkafc = result.getOutput(0)&amp;nbsp; arcpy.SelectLayerByAttribute_management(Output_Layer, "CLEAR_SELECTION", "")&amp;nbsp; # Setting the Map file and the Data Frames: mxd = arcpy.mapping.MapDocument(r"E:\Local Disk (E)\users\Ilan\Projects\Python\Helkot_Maps_tool\MXDproject.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Parcel_Map") [0]&amp;nbsp; # Adding the wanted Helka to the first Data Frame: helka_layer = "Helka" + "_" + Helka&amp;nbsp; arcpy.MakeFeatureLayer_management(helkafc, helka_layer)&amp;nbsp; helkalyr = arcpy.mapping.Layer(helka_layer)&amp;nbsp; arcpy.mapping.AddLayer(df, helkalyr, "TOP")&amp;nbsp; # Setting the Scale for the Data Frame and applying symbology to the Helka:&amp;nbsp; lyr = arcpy.mapping.ListLayers(mxd, helkalyr.name, df)[0]&amp;nbsp; print lyr&amp;nbsp; arcpy.MakeFeatureLayer_management(helkalyr, lyr)&amp;nbsp; result1 = arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", "")&amp;nbsp; if int(arcpy.GetCount_management(lyr).getOutput(0)) &amp;gt; 0: &amp;nbsp;&amp;nbsp;&amp;nbsp; print result1.getOutput(0)&amp;nbsp; df.zoomToSelectedFeatures()&amp;nbsp; df.scale = 8000&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION", "")&amp;nbsp; inputLayer = arcpy.mapping.ListLayers(mxd, helkalyr.name, df)[0] symbologyLayer = arcpy.mapping.Layer("E:\\Local Disk (E)\\users\\Ilan\\Projects\\Python\\Helkot_Maps_tool\\wanted_layer.lyr")&amp;nbsp; arcpy.mapping.UpdateLayer(df, inputLayer, symbologyLayer, True)&amp;nbsp; # Changing text elements in the map to match the Gush and Helka: for textElement in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"): &amp;nbsp; if textElement.text == "map title": &amp;nbsp;&amp;nbsp;&amp;nbsp; textElement.text = "Gush" + " " + Gush + " " + "Helka" + " " + Helka&amp;nbsp; arcpy.RefreshActiveView()&amp;nbsp; # Exporting the Map file to a JPEG file: arcpy.mapping.ExportToJPEG(mxd, Workspace, df_export_width=640, df_export_height=480, resolution=150, &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; world_file=False, color_mode=1, jpeg_quality=100, progressive=False)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much for all the help! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2013 04:41:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/df-zoomtoselectedfeatures-not-working/m-p/163030#M12491</guid>
      <dc:creator>IlanGoichman</dc:creator>
      <dc:date>2013-02-26T04:41:05Z</dc:date>
    </item>
  </channel>
</rss>

