<?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: Python scripting tool fails from Catalog Pane but works in Catalog View in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-scripting-tool-fails-from-catalog-pane-but/m-p/1346865#M69180</link>
    <description>&lt;P&gt;I don't have a solution, but I think I understand why it's happening.&amp;nbsp;&lt;/P&gt;&lt;P&gt;From&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapview-class.htm" target="_blank" rel="noopener"&gt;MapView—ArcGIS Pro | Documentation&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;The&amp;nbsp;&lt;SPAN class=""&gt;activeView&lt;/SPAN&gt;&amp;nbsp;property from the&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/3.1/arcpy/mapping/arcgisproject-class.htm" target="_blank" rel="noopener"&gt;ArcGISProject&lt;/A&gt;&amp;nbsp;class will either return a&amp;nbsp;&lt;SPAN class=""&gt;MapView&lt;/SPAN&gt;&amp;nbsp;object if a map view is active or it will return a&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/3.1/arcpy/mapping/layout-class.htm" target="_blank" rel="noopener"&gt;Layout&lt;/A&gt;&amp;nbsp;or&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/3.1/arcpy/mapping/report-class.htm" target="_blank" rel="noopener"&gt;Report&lt;/A&gt;&amp;nbsp;object if a layout view or report view is active. Any other type of view will return&amp;nbsp;&lt;SPAN class=""&gt;None&lt;/SPAN&gt;.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I'm surprised it's not the opposite. When I have used ActiveView before and ran the tool from the Catalog Pane, the active view returns the map or layout that is active. But the Catalog View returns None. You can test the different returns of the ActiveView in the Python Window of Pro.&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject('current')&lt;BR /&gt;mv = aprx.activeView&lt;BR /&gt;print (mv.name)&lt;/P&gt;&lt;P&gt;For me, my problem was getting an ActiveView when an attribute table was selected. I set my tool to not run until the ActiveView was a map or layout.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You might see if ActiveMap works for your needs, it returns the activated map regardless of view pane.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Nov 2023 19:45:27 GMT</pubDate>
    <dc:creator>Brooks_Wilson</dc:creator>
    <dc:date>2023-11-07T19:45:27Z</dc:date>
    <item>
      <title>Python scripting tool fails from Catalog Pane but works in Catalog View</title>
      <link>https://community.esri.com/t5/python-questions/python-scripting-tool-fails-from-catalog-pane-but/m-p/1346812#M69179</link>
      <description>&lt;P&gt;I have a Python scripting tool that will auto-export a layout to PDF or JPG, update a text box with the export&amp;nbsp; YYMMDDHHMMSS, and log who-what-where-when info to a CSV file.&amp;nbsp; I have been using this code in ArcGIS for years and recently upgraded the tool to work with Pro.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Oddly, the&amp;nbsp; Pro tool works just fine when executed from the Toolbox section of the Catalog View but fails at line 50 when executed from a Catalog Pane.&amp;nbsp; Why would this be the case?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the error message:&lt;/P&gt;&lt;LI-CODE lang="python"&gt; PYTHON ERRORS:
Traceback info:
  File "Z:\GISpublic\GerryG\Python3\SuperSaverArcPro\A1-SuperSaver.atbx#Script_supersaver.py", line 51, in &amp;lt;module&amp;gt;

Error Info:
'NoneType' object has no attribute 'listElements'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;and here is the offending code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    mapnumber = get_time()
    
    #Get the name of the active map view....
    view = aprx.activeView
    
    ele = view.listElements("TEXT_ELEMENT", "mapnumber")[0]
    #assign the mapnumber to the map....
    ele.text = mapnumber&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Here is a link to the tool and the code:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/LummiGIS/Auto-Export-Pro-Layout" target="_blank"&gt;https://github.com/LummiGIS/Auto-Export-Pro-Layout&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 18:07:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-scripting-tool-fails-from-catalog-pane-but/m-p/1346812#M69179</guid>
      <dc:creator>GerryGabrisch</dc:creator>
      <dc:date>2023-11-07T18:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: Python scripting tool fails from Catalog Pane but works in Catalog View</title>
      <link>https://community.esri.com/t5/python-questions/python-scripting-tool-fails-from-catalog-pane-but/m-p/1346865#M69180</link>
      <description>&lt;P&gt;I don't have a solution, but I think I understand why it's happening.&amp;nbsp;&lt;/P&gt;&lt;P&gt;From&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapview-class.htm" target="_blank" rel="noopener"&gt;MapView—ArcGIS Pro | Documentation&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;The&amp;nbsp;&lt;SPAN class=""&gt;activeView&lt;/SPAN&gt;&amp;nbsp;property from the&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/3.1/arcpy/mapping/arcgisproject-class.htm" target="_blank" rel="noopener"&gt;ArcGISProject&lt;/A&gt;&amp;nbsp;class will either return a&amp;nbsp;&lt;SPAN class=""&gt;MapView&lt;/SPAN&gt;&amp;nbsp;object if a map view is active or it will return a&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/3.1/arcpy/mapping/layout-class.htm" target="_blank" rel="noopener"&gt;Layout&lt;/A&gt;&amp;nbsp;or&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/3.1/arcpy/mapping/report-class.htm" target="_blank" rel="noopener"&gt;Report&lt;/A&gt;&amp;nbsp;object if a layout view or report view is active. Any other type of view will return&amp;nbsp;&lt;SPAN class=""&gt;None&lt;/SPAN&gt;.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I'm surprised it's not the opposite. When I have used ActiveView before and ran the tool from the Catalog Pane, the active view returns the map or layout that is active. But the Catalog View returns None. You can test the different returns of the ActiveView in the Python Window of Pro.&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject('current')&lt;BR /&gt;mv = aprx.activeView&lt;BR /&gt;print (mv.name)&lt;/P&gt;&lt;P&gt;For me, my problem was getting an ActiveView when an attribute table was selected. I set my tool to not run until the ActiveView was a map or layout.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You might see if ActiveMap works for your needs, it returns the activated map regardless of view pane.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 19:45:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-scripting-tool-fails-from-catalog-pane-but/m-p/1346865#M69180</guid>
      <dc:creator>Brooks_Wilson</dc:creator>
      <dc:date>2023-11-07T19:45:27Z</dc:date>
    </item>
  </channel>
</rss>

