<?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: arcpy batch to export PDF - problem of refresh mapframe in layout in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1086849#M44171</link>
    <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/567"&gt;@George_Thompson&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Fortunately, I solved the issue.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/11987"&gt;@NatashaManzuiga&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;for your case, you need to probably add the layer to the map like below like map.addLayer(&lt;EM&gt;layerObject or path&lt;/EM&gt;)&lt;/P&gt;&lt;P&gt;Please note that you should not do that within function scope but only global scope.&lt;/P&gt;</description>
    <pubDate>Sat, 07 Aug 2021 09:47:11 GMT</pubDate>
    <dc:creator>ElizabetJaneRoot</dc:creator>
    <dc:date>2021-08-07T09:47:11Z</dc:date>
    <item>
      <title>arcpy batch to export PDF - problem of refresh mapframe in layout</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1034841#M38339</link>
      <description>&lt;P&gt;Dear Everybody, I'm trying to make a batch to export PDF from ArcGIS Pro.&lt;/P&gt;&lt;P&gt;Before I export PDF I need to set definition query for each layers based on values in a table.&lt;/P&gt;&lt;P&gt;Then, there is the export but what I'm getting is always a blank PDF, it looks like it's not refreshing after I set the new extent.&lt;/P&gt;&lt;P&gt;After the script, of course, the layout show me the last extent I set....and it's correct!&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;project  = arcpy.mp.ArcGISProject("CURRENT")
layout   = project.listLayouts("Layout")[0]
mapframe = layout.listElements("MAPFRAME_ELEMENT", "Map Frame")[0]
mapLayers = project.listMaps("Layers")[0]
fields=['field1', 'field2', 'field3', 'field4', 'field5']
search_cursor=arcpy.da.SearchCursor("theTable",fields)
 
for row in search_cursor:
    print(u'{0}, {1}, {2}'.format(row[0], row[1], row[2]))
    queryStr="MAPID="+str(row[0])
    for lyr in mapLayers.listLayers():
        if lyr.supports("DEFINITIONQUERY"):
            lyr.definitionQuery = queryStr
    layer=mapLayers.listLayers("l")[0]
    print(u'{0}, {1}, {2}, {3}'.format(row[0], row[1], row[2], queryStr))       
    layer_extent = mapframe.getLayerExtent(layer, False, False)
    mapframe.camera.setExtent(layer_extent)
    layout.exportToPDF(os.path.join(r"D:\test", f"{row[1]}.pdf"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 11:19:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1034841#M38339</guid>
      <dc:creator>NatashaManzuiga</dc:creator>
      <dc:date>2021-03-10T11:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy batch to export PDF - problem of refresh mapframe in layout</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1085671#M44043</link>
      <description>&lt;P&gt;I encountered the same issue. I would like to escalate the priority of this question.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 13:21:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1085671#M44043</guid>
      <dc:creator>ElizabetJaneRoot</dc:creator>
      <dc:date>2021-08-04T13:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy batch to export PDF - problem of refresh mapframe in layout</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1085684#M44045</link>
      <description>&lt;P&gt;If you need immediate assistance, I would recommend contacting Esri Technical Support to work with an analyst on this.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 13:41:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1085684#M44045</guid>
      <dc:creator>George_Thompson</dc:creator>
      <dc:date>2021-08-04T13:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy batch to export PDF - problem of refresh mapframe in layout</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1086849#M44171</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/567"&gt;@George_Thompson&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Fortunately, I solved the issue.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/11987"&gt;@NatashaManzuiga&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;for your case, you need to probably add the layer to the map like below like map.addLayer(&lt;EM&gt;layerObject or path&lt;/EM&gt;)&lt;/P&gt;&lt;P&gt;Please note that you should not do that within function scope but only global scope.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Aug 2021 09:47:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1086849#M44171</guid>
      <dc:creator>ElizabetJaneRoot</dc:creator>
      <dc:date>2021-08-07T09:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy batch to export PDF - problem of refresh mapframe in layout</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1361048#M76404</link>
      <description>&lt;P&gt;I'm having this same issue. How did you resolve this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found that my code works as expected if executed as a python notebook in pro, but if I try to run in the python window, I get the mysterious empty layout.&lt;/P&gt;&lt;P&gt;The layer I would like to display on the layout is already in the map, so I don't think ElizabethJaneRoot's comment applied.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/567"&gt;@George_Thompson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 18:55:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1361048#M76404</guid>
      <dc:creator>JamesTurner2</dc:creator>
      <dc:date>2023-12-14T18:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy batch to export PDF - problem of refresh mapframe in layout</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1484844#M84156</link>
      <description>&lt;P&gt;I've been having this same issue with multiple projects, but have found a workaround based on this thread!&lt;/P&gt;&lt;P&gt;There was mention of adding the layer, but then also a comment that it would not apply if the layer was already in the map. Well I thought, that&amp;nbsp;&lt;EM&gt;is&lt;/EM&gt; kind of like the refresh that I want...&lt;/P&gt;&lt;P&gt;So even though all the layers area already in the map I'm trying to export, I (programmatically) removed them all and then re-added from a .lyrx file right before I exported the map. Currently working for me and this solves a BIG headache I've battled for a few months now!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 22:28:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1484844#M84156</guid>
      <dc:creator>AlderMaps</dc:creator>
      <dc:date>2024-06-04T22:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy batch to export PDF - problem of refresh mapframe in layout</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1485268#M84184</link>
      <description>&lt;P&gt;Interesting follow up. I don't recall if I tried removing and re-adding the layer. I settled on using a python notebook instead, which while slowed, made things easier overall. I didn't have much experience with notebooks before, but they are a great tool for troubleshooting and I had a lot of that to do!&lt;/P&gt;&lt;P&gt;My organization is dragging on updating to Pro 3.x so maybe I will revisit moving to a script instead of a notebook when that happens. I think there are some other new functions I'll be able to incorporate when we upgrade as well.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 11:57:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-batch-to-export-pdf-problem-of-refresh/m-p/1485268#M84184</guid>
      <dc:creator>JamesTurner2</dc:creator>
      <dc:date>2024-06-05T11:57:29Z</dc:date>
    </item>
  </channel>
</rss>

