<?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: Adding Zoom to Selected feature to execute at the end of model. in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535913#M17791</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Could it be the layer in line 5 should be Layer. It's very case sensitive.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;df.zoomToSelectedFeatures(layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;change to:&amp;nbsp;&amp;nbsp; df.zoomToSelectedFeatures(Layer)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Sep 2010 16:14:46 GMT</pubDate>
    <dc:creator>SueBreeden</dc:creator>
    <dc:date>2010-09-10T16:14:46Z</dc:date>
    <item>
      <title>Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535899#M17777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings everyone, I work for a retailer and we have a shapefile of all our stores and they are individually ID'ed with a store number.&amp;nbsp; I have a very simple model that allows the user to input the store number and then the model selects it.&amp;nbsp; Ideally I would like the model to automatically zoom to the selected feature, right now I have to click the "zoom to feature" tool as a work around but I would like to not have to do that.&amp;nbsp; Do I have to write a custom scrip or is there an option I can just check in model builder?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jul 2010 17:24:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535899#M17777</guid>
      <dc:creator>RyanFurlong</dc:creator>
      <dc:date>2010-07-06T17:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535900#M17778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can't do it in v9.3, but now in v10.0 there is a zoomToSelectedFeatures() method as part of the arcpy.mapping module. This would probably have to be in script format (not modelbuilder) to work though....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jul 2010 18:28:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535900#M17778</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-07-06T18:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535901#M17779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That is a shame to hear that, I was hoping it would be a simple thing to add.&amp;nbsp; Anyone else have ideas on different ways to accomplish this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jul 2010 19:27:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535901#M17779</guid>
      <dc:creator>RyanFurlong</dc:creator>
      <dc:date>2010-07-06T19:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535902#M17780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can write a simple script and add it as part of the model, that way you stay in the MB environment.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jul 2010 19:34:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535902#M17780</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-07-07T19:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535903#M17781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It might be simple for you, but I have never written a script. I'm not even sure i what editor to write it, let alone what syntax to use or where to store it. Can anyone point me to an idiots guide to script writting?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 13:19:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535903#M17781</guid>
      <dc:creator>GeorgeDunbar</dc:creator>
      <dc:date>2010-07-19T13:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535904#M17782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well the whole script in 10 would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
MXD=arcpy.mapping.mapdocument('current') #get access to the current mxd
dataframe = arcpy.mapping.ListDataFrames(MXD, "Layers")[0] #grab the dataframe object you want (probably named Layers)
dataframe.zoomToSelectedFeatures() #zoom to the feature in memory
arcpy.RefreshActiveView() #refresh the map so that the extent change shows up
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This is written in python 2.6 in the IDLE IDE and saved really wherever you want then added to a toolbox in your toolbox dialog. The help documents are a great place to start for learning this stuff. You could do this in ArcObjects but thats a giant hassle and a whole other ball game code wise. Python.org has lots of resources to get started with python in general and if you want something professionally taught ESRI and many others offer 'Python for ArcGIS' classes. I learned what I know about python from Learning Python by O'Rielly, the ArcGIS help pages and lurking in #python on IRC.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:16:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535904#M17782</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2021-12-11T23:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535905#M17783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is great!&amp;nbsp; Thank you clm42!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 21:27:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535905#M17783</guid>
      <dc:creator>RyanFurlong</dc:creator>
      <dc:date>2010-07-19T21:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535906#M17784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have the python script that will zoom to selected features. It works great outside of model builder, however; when I add the script to a model and connect it to the output of Select Layer By Attributes it doesn't work. The output is set as a precondition before the script runs. I don't receive any errors when I run the model, it just doesn't zoom to the selected features. Any insight to this problem would be helpful. Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jul 2010 16:26:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535906#M17784</guid>
      <dc:creator>SueBreeden</dc:creator>
      <dc:date>2010-07-21T16:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535907#M17785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If it works outside of arcmap I assume you are using ArcGIS 10. Try selecting a feature by hand and then pasting each line from the script into the python window in ArcMap one at a time. There may be a typo in the code that will rear its head when you are using the code interactivly. Are there multiple data frames in the map?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jul 2010 18:23:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535907#M17785</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-07-21T18:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535908#M17786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Good morning, thanks for the fast response. I am using Arcgis 10, the code works great in the python window. I can select a parcel with the select tool, or from the attribute table and the code in the python window works. I can also build an expression using the Select by Attributes in Arcmap and the code works in the python window. I have saved the code as a python script file. I can double click the script outside of the python window and it works great as well.The only time it doesn't zoom to the selected feature is when I add the script file to a geoprocess in model builder. It doesn't stop the process or give an error it just doesn't zoom to the selected feature.&amp;nbsp; I can remove the script file from my model and run the process,and then double click the script file outside of the model and it will work, it just doesn't work within model builder.I have only one data frame and one shapefile added to the map doc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code for zoom to selected script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument('CURRENT')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.zoomToSelectedFeatures()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have attached an image of my simple model. Thanks for your help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jul 2010 13:23:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535908#M17786</guid>
      <dc:creator>SueBreeden</dc:creator>
      <dc:date>2010-07-22T13:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535909#M17787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I cant imagine why this would be causing a problem, but could you try modifiying the model so that you dont use a feature layer? If the shapefile is already loaded into ArcMap you shouldnt need to make it a feature layer in the model.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jul 2010 14:15:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535909#M17787</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-07-22T14:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535910#M17788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks so much for the help. The Make Feature Layer was the problem in the model. I removed it and all works well; my model with script runs great now. Appreciate the help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jul 2010 14:30:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535910#M17788</guid>
      <dc:creator>SueBreeden</dc:creator>
      <dc:date>2010-07-22T14:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535911#M17789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Would anyone know how to code something similar as an add-in?&amp;nbsp; I am trying to do it myself but I am not having much luck.&amp;nbsp; What I would want the add in to do is select an attribute in 1 specified layer based on user input say like id number for the attribute and then just zoom to it.&amp;nbsp; It would have to have an input box to enter in the feature ID then a button to initiate the select and zoom to feature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pseudo code:&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;input number = feature ID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select feature based on entered number&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;zoom to feature&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jul 2010 17:35:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535911#M17789</guid>
      <dc:creator>RyanFurlong</dc:creator>
      <dc:date>2010-07-22T17:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535912#M17790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have built a simple model for a user to select a polygon, now I want have the view extent zoom to that selected feature.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I saw the above script sample and added it to the end of the model, but it would not work.&amp;nbsp; After searching around the web, found another similar example that zoomed to a scaling of the selected extent, but this does not work either.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code and the error message.&amp;nbsp; Any help would be greatly appreciated.&amp;nbsp; Im just learning Python and am trying to figure this out on the fly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = ("G:\search_zoom\search_zoom.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = (mxd, "PLSS_u1483")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer = (mxd, "section", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.zoomToSelectedFeatures(layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.scale = df.scale * 1.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;File "G:\search_zoom\zoom2selected2.py", line 5, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; df.zoomToSelectedFeatures(layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'str' object has no attribute 'zoomToSelectedFeatures'&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Sep 2010 16:09:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535912#M17790</guid>
      <dc:creator>MikeHouts</dc:creator>
      <dc:date>2010-09-10T16:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535913#M17791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Could it be the layer in line 5 should be Layer. It's very case sensitive.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;df.zoomToSelectedFeatures(layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;change to:&amp;nbsp;&amp;nbsp; df.zoomToSelectedFeatures(Layer)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Sep 2010 16:14:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535913#M17791</guid>
      <dc:creator>SueBreeden</dc:creator>
      <dc:date>2010-09-10T16:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535914#M17792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the response.&amp;nbsp; I caught that after posting, thats not it.&amp;nbsp; I tried changing that line a lot of ways and the error always changes to whatever I change the "variable" to as I tried substituing in different expressions for what df. extent = &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'str' object has no attribute 'zoomToSelectedFeatures'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'str' object has no attribute 'Layer'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'str' object has no attribute 'section'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'str' object has no attribute 'selected'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'str' object has no attribute 'getSelectedExtent'&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Sep 2010 16:33:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535914#M17792</guid>
      <dc:creator>MikeHouts</dc:creator>
      <dc:date>2010-09-10T16:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535915#M17793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The problem is the line where you define your dataframe. It should be df=arcpy.mapping.ListDataFrames(MXD, "Layers")[0] instead of df = (mxd, "PLSS_u1483")[0].&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Sep 2010 17:02:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535915#M17793</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-09-10T17:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535916#M17794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I had that originally...tried changing it back just now, so script is currently &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = ("G:\search_zoom\search_zoom.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df=arcpy.mapping.ListDataFrames(MXD, "Layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer = (mxd, "section", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.zoomToSelectedFeatures(layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.scale = df.scale * 1.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;with error of:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;File "G:\kpw\arc_server\auto_assessment\search_zoom\zoom2selected2.py", line 3, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; df=arcpy.mapping.ListDataFrames(MXD, "Layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NameError: name 'MXD' is not defined&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I originally had the arcpy.mapping.... starting line 2 as well, but that gave me the same error, so I removed it and just went straight to a direct reference and then it read fine until the next arcpy.mapping....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What am I missing?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Sep 2010 17:12:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535916#M17794</guid>
      <dc:creator>MikeHouts</dc:creator>
      <dc:date>2010-09-10T17:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535917#M17795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks for the response.&amp;nbsp; I caught that after posting, thats not it.&amp;nbsp; I tried changing that line a lot of ways and the error always changes to whatever I change the "variable" to as I tried substituing in different expressions for what df. extent = &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;AttributeError: 'str' object has no attribute 'zoomToSelectedFeatures'&lt;BR /&gt;AttributeError: 'str' object has no attribute 'Layer'&lt;BR /&gt;AttributeError: 'str' object has no attribute 'section'&lt;BR /&gt;AttributeError: 'str' object has no attribute 'selected'&lt;BR /&gt;AttributeError: 'str' object has no attribute 'getSelectedExtent'&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I got this to work for me, fill in your dataframe name and shapefile name where indicated. Make sure map is open and a feature is selected. This zooms to selected feature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument('CURRENT')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd,"put name of top dataframe here")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer = (mxd, "put name of first shapefile in top dataframe here", df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.zoomToSelectedFeatures()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Sep 2010 17:22:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535917#M17795</guid>
      <dc:creator>SueBreeden</dc:creator>
      <dc:date>2010-09-10T17:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Zoom to Selected feature to execute at the end of model.</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535918#M17796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I had that originally...tried changing it back just now, so script is currently &lt;BR /&gt;&lt;BR /&gt;import arcpy&lt;BR /&gt;mxd = ("G:\search_zoom\search_zoom.mxd")&lt;BR /&gt;df=arcpy.mapping.ListDataFrames(MXD, "Layers")[0]&lt;BR /&gt;Layer = (mxd, "section", df)[0]&lt;BR /&gt;df.zoomToSelectedFeatures(layer)&lt;BR /&gt;df.scale = df.scale * 1.1&lt;BR /&gt;arcpy.RefreshActiveView()&lt;BR /&gt;&lt;BR /&gt;with error of:&lt;BR /&gt;&lt;BR /&gt;File "G:\kpw\arc_server\auto_assessment\search_zoom\zoom2selected2.py", line 3, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; df=arcpy.mapping.ListDataFrames(MXD, "Layers")[0]&lt;BR /&gt;NameError: name 'MXD' is not defined&lt;BR /&gt;&lt;BR /&gt;I originally had the arcpy.mapping.... starting line 2 as well, but that gave me the same error, so I removed it and just went straight to a direct reference and then it read fine until the next arcpy.mapping....&lt;BR /&gt;&lt;BR /&gt;What am I missing?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Python is case sensitive and the error is indicating that you have changed the case of the mxd variable in the 3rd line, which rather than using the assignment of the variable in the second line is being interpreted as a new unassigned variable.&amp;nbsp; You have the same problem with the variable called Layer/layer.&amp;nbsp; Be consistent with your variable spelling cases.&amp;nbsp; Change the code to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
mxd = ("G:\search_zoom\search_zoom.mxd")
df=arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
Layer = (mxd, "section", df)[0]
df.zoomToSelectedFeatures(Layer)
df.scale = df.scale * 1.1
arcpy.RefreshActiveView()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:16:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-zoom-to-selected-feature-to-execute-at-the/m-p/535918#M17796</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T23:16:50Z</dc:date>
    </item>
  </channel>
</rss>

