<?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: mapframe.zoomToAllLayers(True) return Traceback/Runtime Error in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/mapframe-zoomtoalllayers-true-return-traceback/m-p/1495946#M84832</link>
    <description>&lt;P&gt;I found the issue - Layout needs to be activated, then the code works.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jun 2024 14:15:12 GMT</pubDate>
    <dc:creator>IlkaIllers1</dc:creator>
    <dc:date>2024-06-21T14:15:12Z</dc:date>
    <item>
      <title>mapframe.zoomToAllLayers(True) return Traceback/Runtime Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/mapframe-zoomtoalllayers-true-return-traceback/m-p/1495850#M84830</link>
      <description>&lt;P&gt;I am trying to go through the features of a feature class one by one, selecting one feature class and zooming to it.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx= arcpy.mp.ArcGISProject(aprx)
l = aprx.listLayouts("Layout")[0]
mf = l.listElements('MAPFRAME_ELEMENT','Map Frame')[0]
#make feature layer or points
f2 = fc
#make feature layer
fl = arcpy.management.MakeFeatureLayer(f2,f2)
#loop through features
with arcpy.da.SearchCursor(fl, ['OBJECTID']) as cursor:
    for row in cursor:
        # Find OBJECTID of the row
        oid = row[0]
        # Select the row
        where_clause = "{} = {}".format(arcpy.AddFieldDelimiters(fl, "OBJECTID"), oid)
        arcpy.management.SelectLayerByAttribute(fl, "NEW_SELECTION", where_clause)
        #zoom to selection
        mf.zoomToAllLayers(True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run this in a completely new aprx, the code runs through without errors - but zooms to the extent of the basemap, even though it should zoom only to selected features. Once I remove the basemap, I get a Traceback:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 17, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 5541, in zoomToAllLayers&lt;BR /&gt;return convertArcObjectToPythonObject(self._arc_object.zoomToAllLayers(*gp_fixargs((selection_only, symbolized_extent), True)))&lt;BR /&gt;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&lt;BR /&gt;RuntimeError&lt;/P&gt;&lt;P&gt;Even if I add the basemap again, this is all I get from that point on. What am I doing wrong here?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2024 12:24:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/mapframe-zoomtoalllayers-true-return-traceback/m-p/1495850#M84830</guid>
      <dc:creator>IlkaIllers1</dc:creator>
      <dc:date>2024-06-21T12:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: mapframe.zoomToAllLayers(True) return Traceback/Runtime Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/mapframe-zoomtoalllayers-true-return-traceback/m-p/1495946#M84832</link>
      <description>&lt;P&gt;I found the issue - Layout needs to be activated, then the code works.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2024 14:15:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/mapframe-zoomtoalllayers-true-return-traceback/m-p/1495946#M84832</guid>
      <dc:creator>IlkaIllers1</dc:creator>
      <dc:date>2024-06-21T14:15:12Z</dc:date>
    </item>
  </channel>
</rss>

