<?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: Zoom To Layer (VBA) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555161#M43379</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Have you considered using arcpy.mapping?&amp;nbsp; It is a great substitute for many common tasks and can accomplish what you are trying to do.&lt;BR /&gt;&lt;BR /&gt;You can change query definitions on a layer using the layer object:&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For good resources on how to get started, check out:&lt;BR /&gt;&lt;A href="http://blogs.esri.com/esri/arcgis/2011/09/30/new-resources-available-for-getting-started-with-python-map-automation/"&gt;http://blogs.esri.com/esri/arcgis/2011/09/30/new-resources-available-for-getting-started-with-python-map-automation/&lt;/A&gt;&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 work for the gov't and because of that it's virtually impossible to convince IT that I need additional components installed and if I do it'll take months of hassle. Does arcpy.mapping require installation of something python related or is it defaulted in the ARCMap install?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 May 2012 13:58:48 GMT</pubDate>
    <dc:creator>JoelMadero</dc:creator>
    <dc:date>2012-05-08T13:58:48Z</dc:date>
    <item>
      <title>Zoom To Layer (VBA)</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555157#M43375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me start by saying I have never coded in GIS programs before, I know basic, some C/C++, and a few others I've dabbled in. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I'm looking for is how would I go about automating a query on a layer, zoom to the layer, change a number that is on the map (MAP # which is based on a field that is located in the zoomed to layer), then print it. For the last couple years I've had to manually print out hundreds of maps for this project and I think it can be automated relatively easily.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think doing this one step at a time would be best. So how do I just zoom to a layer, I have this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Sub Multiple_Polls()
Dim pDoc As IMxDocument

Set pDoc = ThisDocument

Dim pMap As IMap

Set pMap = pDoc.FocusMap



Dim pLayer As IFeatureLayer

Dim pFSel As IFeatureSelection

Set pLayer = pMap.Layer(3)

Set pFSel = pLayer



'Get the selected features

Dim pSelSet As ISelectionSet

Set pSelSet = pFSel.SelectionSet



Dim pEnumGeom As IEnumGeometry

Dim pEnumGeomBind As IEnumGeometryBind



Set pEnumGeom = New EnumFeatureGeometry

Set pEnumGeomBind = pEnumGeom

pEnumGeomBind.BindGeometrySource Nothing, pSelSet



Dim pGeomFactory As IGeometryFactory

Set pGeomFactory = New GeometryEnvironment



Dim pGeom As IGeometry

Set pGeom = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom)



pDoc.ActiveView.Extent = pGeom.Envelope

pDoc.ActiveView.Refresh
End Sub

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But how do I set the correct layer, I changed this line: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Set pLayer = pMap.Layer(3)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;to different numbers but all just seem to refresh the map, not actually zoom to layer. Thanks in advance&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 16:08:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555157#M43375</guid>
      <dc:creator>JoelMadero</dc:creator>
      <dc:date>2012-05-04T16:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Automate Querry, Zoom To, Print</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555158#M43376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems that what would do the trick for you is using the Data Driven Pages:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1- Activate the Data Driven Pages toolbar&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2- Click the Data Driven Page setup button on the very left toolbar.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3- Choose the feature layer you'll use&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4- Control the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;zoom&lt;/SPAN&gt;&lt;SPAN&gt; (or scale) under the second tab "Data Driven Scale"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]14105[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;5- Use Dynamic text to display map specific info such as Map#, page#&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for the query part, it's not clear to me what you need to do, so I'll wait for an example of what you need to accomplish.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 16:57:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555158#M43376</guid>
      <dc:creator>waleedelmarimi</dc:creator>
      <dc:date>2012-05-04T16:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Automate Querry, Zoom To, Print</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555159#M43377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply, I'll give a bit more detail:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What we have are consolidation #'s that are polygons. Currently the manual method of printing is to query a consolidation #, right click on the layer, zoom to the layer (which then zooms to the queried polygon only), then we manually change the Consolidation # that is on the page (just straight text), then we print.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Furthermore each map is actually two consolidation #'s. So I actually query both consolidations, zoom to them, then I print two identical maps just with the consolidation # changed in the upper right corner of the map.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 17:02:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555159#M43377</guid>
      <dc:creator>JoelMadero</dc:creator>
      <dc:date>2012-05-04T17:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom To Layer (VBA)</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555160#M43378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you considered using arcpy.mapping?&amp;nbsp; It is a great substitute for many common tasks and can accomplish what you are trying to do.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can change query definitions on a layer using the layer object:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For good resources on how to get started, check out:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://blogs.esri.com/esri/arcgis/2011/09/30/new-resources-available-for-getting-started-with-python-map-automation/"&gt;http://blogs.esri.com/esri/arcgis/2011/09/30/new-resources-available-for-getting-started-with-python-map-automation/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2012 14:40:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555160#M43378</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2012-05-07T14:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom To Layer (VBA)</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555161#M43379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Have you considered using arcpy.mapping?&amp;nbsp; It is a great substitute for many common tasks and can accomplish what you are trying to do.&lt;BR /&gt;&lt;BR /&gt;You can change query definitions on a layer using the layer object:&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For good resources on how to get started, check out:&lt;BR /&gt;&lt;A href="http://blogs.esri.com/esri/arcgis/2011/09/30/new-resources-available-for-getting-started-with-python-map-automation/"&gt;http://blogs.esri.com/esri/arcgis/2011/09/30/new-resources-available-for-getting-started-with-python-map-automation/&lt;/A&gt;&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 work for the gov't and because of that it's virtually impossible to convince IT that I need additional components installed and if I do it'll take months of hassle. Does arcpy.mapping require installation of something python related or is it defaulted in the ARCMap install?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2012 13:58:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555161#M43379</guid>
      <dc:creator>JoelMadero</dc:creator>
      <dc:date>2012-05-08T13:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom To Layer (VBA)</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555162#M43380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I work for the gov't and because of that it's virtually impossible to convince IT that I need additional components installed and if I do it'll take months of hassle. Does arcpy.mapping require installation of something python related or is it defaulted in the ARCMap install?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Python and the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v000000v7000000"&gt;arcpy&lt;/A&gt;&lt;SPAN&gt; module are installed by default with ArcGIS Desktop.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 May 2012 14:08:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555162#M43380</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-05-08T14:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom To Layer (VBA)</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555163#M43381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Python and the &lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v000000v7000000"&gt;arcpy&lt;/A&gt; module are installed by default with ArcGIS Desktop.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you much! So where I am now, I have figured out the zoom to feature but I have only figured out zoom to selected, not zoom to queried. I can probably work with this BUT if possible I'd like to at least know if it's possible to zoom to queried. This is the same as right click on layer -&amp;gt; zoom to layer. This automatically zooms to queried layer. Thanks again, making progress &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, 08 May 2012 14:55:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555163#M43381</guid>
      <dc:creator>JoelMadero</dc:creator>
      <dc:date>2012-05-08T14:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom To Layer (VBA)</title>
      <link>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555164#M43382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can do this two ways.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "myLayer")[0]

#Zoom to all selected features in data frame
df.zoomToSelectedFeatures()

#Zoom to selected features for a specific layer.
df.extent = lyr.getSelectedExtent()

arcpy.RefreshActiveView()
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:59:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-to-layer-vba/m-p/555164#M43382</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-12-11T23:59:11Z</dc:date>
    </item>
  </channel>
</rss>

