<?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>idea ArcGISProject.activeView: Return table, etc. views. in ArcGIS Pro Ideas</title>
    <link>https://community.esri.com/t5/arcgis-pro-ideas/arcgisproject-activeview-return-table-etc-views/idi-p/1339255</link>
    <description>&lt;P&gt;So, a colleague of mine recently ran into an issue where a tool was failing in updateParameters() because on a particular line, the list index was out of range.&lt;/P&gt;&lt;P&gt;Is the code in question (Error caused by line 3 in this snippet):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject('current')
mv = aprx.activeView
if str(mv).split(' ')[0].split('.')[2] == "Layout": #if a activeView returns a layout, get the map frame from it
    mf = mv.listElements("MAPFRAME_ELEMENT")[0].map
else: #it's a map view
    mf = mv.map&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What we figured out is that trying to run the tool with an attribute table open and active was causing the issue.&lt;/P&gt;&lt;P&gt;Essentially, because ArcGISProject.activeView only sees Map or Layout Views, it was feeding line 3 a&amp;nbsp;&lt;STRONG&gt;None&lt;/STRONG&gt; object, which can't be split, acted upon, etc.&lt;/P&gt;&lt;P&gt;I'd prefer to avoid this sort of thing in the future.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here are two options I can think of to fix this&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If a table, etc. is open and active, return the map it belongs to&lt;UL&gt;&lt;LI&gt;Alternatively, return the last active map/layout.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Recognize table, etc views in Active view, be able to check the type of the result.&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Wed, 18 Oct 2023 21:11:44 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2023-10-18T21:11:44Z</dc:date>
    <item>
      <title>ArcGISProject.activeView: Return table, etc. views.</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/arcgisproject-activeview-return-table-etc-views/idi-p/1339255</link>
      <description>&lt;P&gt;So, a colleague of mine recently ran into an issue where a tool was failing in updateParameters() because on a particular line, the list index was out of range.&lt;/P&gt;&lt;P&gt;Is the code in question (Error caused by line 3 in this snippet):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject('current')
mv = aprx.activeView
if str(mv).split(' ')[0].split('.')[2] == "Layout": #if a activeView returns a layout, get the map frame from it
    mf = mv.listElements("MAPFRAME_ELEMENT")[0].map
else: #it's a map view
    mf = mv.map&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What we figured out is that trying to run the tool with an attribute table open and active was causing the issue.&lt;/P&gt;&lt;P&gt;Essentially, because ArcGISProject.activeView only sees Map or Layout Views, it was feeding line 3 a&amp;nbsp;&lt;STRONG&gt;None&lt;/STRONG&gt; object, which can't be split, acted upon, etc.&lt;/P&gt;&lt;P&gt;I'd prefer to avoid this sort of thing in the future.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here are two options I can think of to fix this&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If a table, etc. is open and active, return the map it belongs to&lt;UL&gt;&lt;LI&gt;Alternatively, return the last active map/layout.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Recognize table, etc views in Active view, be able to check the type of the result.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 18 Oct 2023 21:11:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/arcgisproject-activeview-return-table-etc-views/idi-p/1339255</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-10-18T21:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGISProject.activeView: Return table, etc. views.</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/arcgisproject-activeview-return-table-etc-views/idc-p/1340439#M26658</link>
      <description>&lt;P&gt;It appears this functionality is found in .activeMap.&lt;/P&gt;&lt;P&gt;Please mark this thread as already offered.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 12:52:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/arcgisproject-activeview-return-table-etc-views/idc-p/1340439#M26658</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-10-23T12:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGISProject.activeView: Return table, etc. views. - Status changed to: Already Offered</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/arcgisproject-activeview-return-table-etc-views/idc-p/1344795#M26789</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/458875"&gt;@AlfredBaldenweck&lt;/a&gt;&amp;nbsp;this can be accomplished a little easier using either type() or isInstance, for example,&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;p = arcpy.mp.ArcGISProject('current')&lt;BR /&gt;av = p.activeView&lt;BR /&gt;if type(av) == arcpy._mp.MapView:&lt;BR /&gt;print("MAPVIEW")&lt;BR /&gt;elif type(av) == arcpy._mp.Layout:&lt;BR /&gt;print("LAYOUT")&lt;BR /&gt;else:&lt;BR /&gt;print("NONE")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;or&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;p = arcpy.mp.ArcGISProject('current')&lt;BR /&gt;if isinstance(pactiveView, arcpy._mp.Layout):&lt;BR /&gt;# work with the layout&lt;BR /&gt;elif isinstance(p.activeView, arcpy._mp.Map):&lt;BR /&gt;# work with the map&lt;BR /&gt;else:&lt;BR /&gt;# Nothing found, active element isn't a map or layout&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Jeff - Layout and arcpy.mp teams&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 02:18:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/arcgisproject-activeview-return-table-etc-views/idc-p/1344795#M26789</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2023-11-02T02:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGISProject.activeView: Return table, etc. views.</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/arcgisproject-activeview-return-table-etc-views/idc-p/1344991#M26801</link>
      <description>&lt;P&gt;Hey Jeff, I actually need to eat crow again here.&lt;/P&gt;&lt;P&gt;I talked to my colleague and got a better understanding of what the issue was.&lt;/P&gt;&lt;P&gt;He created a tool to zoom to a particular geographic location (e.g. USGS quad). You select the state you want, then it grabs the correct quads for that state for you to choose. The third and final parameter is the map you zoom to, which is calculated using your active view.&lt;/P&gt;&lt;P&gt;The problem with this is that it will return &lt;STRONG&gt;None &lt;/STRONG&gt;if a table, etc. is active, and then the entire thing will pre-emptively break. Once this happens, the most reliable way of fixing it is to just re-open the tool and trying again.&lt;/P&gt;&lt;P&gt;activeMap will actually do the right thing and return the map the table belongs to, but the thing with activeMap is that you can't change the view at all.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The current work around is to use setErrorMessage() to tell the user to make a map or layout view active again, but it would be a lot easier if we could have tables, etc. return the map view they belong to.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 14:32:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/arcgisproject-activeview-return-table-etc-views/idc-p/1344991#M26801</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-11-02T14:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGISProject.activeView: Return table, etc. views.</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/arcgisproject-activeview-return-table-etc-views/idc-p/1345016#M26804</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/458875"&gt;@AlfredBaldenweck&lt;/a&gt;&amp;nbsp;have you tried using functions like Map.openView()?&amp;nbsp; We currently don't have the ability to specifically close or even reference a particular view because they are not named and you can have many views open that all point to the same map, for example.&amp;nbsp; So we introduced openView on Map, Layout, and Report objects.&amp;nbsp; It will open and activate a view for that specific object.&amp;nbsp; If you don't want to keep opening extra views, we also introduced ArcGISProject.closeViews().&amp;nbsp; THis was you can close everything and open a specific, active view. I hope this helps your scenario.&lt;/P&gt;&lt;P&gt;Jeff - Layout and arcpy.mp teams&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 15:11:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/arcgisproject-activeview-return-table-etc-views/idc-p/1345016#M26804</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2023-11-02T15:11:31Z</dc:date>
    </item>
  </channel>
</rss>

