<?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: Inconsistent export to pdf results. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/inconsistent-export-to-pdf-results/m-p/1005356#M59159</link>
    <description>&lt;P&gt;Hi Randy,&lt;/P&gt;&lt;P&gt;without running your code, I'm just guessing the missing outputs (or bookmarks) are dropped out because code to call the&amp;nbsp;exportToPDF method isn't called in the if bk.name== pageName block.&lt;/P&gt;&lt;P&gt;you could experiment with:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if s.listBookmarks(): # check presence of bookmarks
    for bk in s.listBookmarks():
        if bk.name == pageName:
            arcpy.AddMessage("&amp;gt; Zooming to bookmark: "+bk.name+"...")
            sf.zoomToBookmark(bk)
                
            arcpy.AddMessage(out_folder+"\\Election_2020_"+pageName+".pdf") 
            # call exportToPDF here for the bookmark     
            l.exportToPDF(out_folder+"\\Election_2020_"+pageName+".pdf")
        
else: # exportToPDF when there are no bookmarks
    arcpy.AddMessage(out_folder+"\\Election_2020_"+pageName+".pdf")
    l.exportToPDF(out_folder+"\\Election_2020_"+pageName+".pdf")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if this isn't working, then perhaps look at the doc about the&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/classes/result.htm" target="_self"&gt;Result&lt;/A&gt; object.&lt;/P&gt;&lt;P&gt;There is an example in there where you can wait for the success signal in a while loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if the&amp;nbsp;zoomToBookmark method returns a result.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;while result.status &amp;lt; 4:
    time.sleep(0.2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 29 Nov 2020 10:17:58 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2020-11-29T10:17:58Z</dc:date>
    <item>
      <title>Inconsistent export to pdf results.</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-export-to-pdf-results/m-p/1005058#M59134</link>
      <description>&lt;P&gt;I have&amp;nbsp; a simple python script that updates a scene bookmark for each of 50 map series map bookmarks and exports a layout. I run it for each of 50 map series bookmarks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works fine, but some of the outputs are missing features and I need to redo them. I'm guessing it's going "too fast" and some of the layouts are exporting before the layout has fully drawn all the features. Is there a way to slow it down, or tell it to wait till everything's drawn fully before it exports?&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Randy McGregor&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#
# Export map series and update scene bookmarks.
#
import arcpy, os, sys, time

out_folder = arcpy.GetParameterAsText(0)

p = arcpy.mp.ArcGISProject("CURRENT")
l = p.listLayouts()[0]
#
# Get the scene:
#
for m in p.listMaps():
    
    if m.mapType == 'SCENE':
        s = m
        break
#
# Get the scene frame:
#
for mf in l.listElements('MAPFRAME_ELEMENT'):

    if mf.camera.mode != "MAP":
        sf = mf
        break
#
# Run the map series:
#
if not l.mapSeries is None:
  ms = l.mapSeries
  
  if ms.enabled:
      
    for pageNum in range(1, ms.pageCount + 1):
      ms.currentPageNumber = pageNum
      time.sleep(5)
      pageName = ms.pageRow.STATE_NAME
      arcpy.AddMessage("&amp;gt; "+pageName+"...")
      arcpy.AddMessage("&amp;gt; "+str(pageNum))
      #
      # Find the corresponding scene bookmark:
      #
      for bk in s.listBookmarks():
          
          if bk.name == pageName:
              arcpy.AddMessage("&amp;gt; Zooming to bookmark: "+bk.name+"...")
              sf.zoomToBookmark(bk)
        
      arcpy.AddMessage(out_folder+"\\Election_2020_"+pageName+".pdf")             
      l.exportToPDF(out_folder+"\\Election_2020_"+pageName+".pdf")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 17:36:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-export-to-pdf-results/m-p/1005058#M59134</guid>
      <dc:creator>RandyMcGregor_Home</dc:creator>
      <dc:date>2020-11-26T17:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent export to pdf results.</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-export-to-pdf-results/m-p/1005356#M59159</link>
      <description>&lt;P&gt;Hi Randy,&lt;/P&gt;&lt;P&gt;without running your code, I'm just guessing the missing outputs (or bookmarks) are dropped out because code to call the&amp;nbsp;exportToPDF method isn't called in the if bk.name== pageName block.&lt;/P&gt;&lt;P&gt;you could experiment with:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if s.listBookmarks(): # check presence of bookmarks
    for bk in s.listBookmarks():
        if bk.name == pageName:
            arcpy.AddMessage("&amp;gt; Zooming to bookmark: "+bk.name+"...")
            sf.zoomToBookmark(bk)
                
            arcpy.AddMessage(out_folder+"\\Election_2020_"+pageName+".pdf") 
            # call exportToPDF here for the bookmark     
            l.exportToPDF(out_folder+"\\Election_2020_"+pageName+".pdf")
        
else: # exportToPDF when there are no bookmarks
    arcpy.AddMessage(out_folder+"\\Election_2020_"+pageName+".pdf")
    l.exportToPDF(out_folder+"\\Election_2020_"+pageName+".pdf")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if this isn't working, then perhaps look at the doc about the&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/classes/result.htm" target="_self"&gt;Result&lt;/A&gt; object.&lt;/P&gt;&lt;P&gt;There is an example in there where you can wait for the success signal in a while loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if the&amp;nbsp;zoomToBookmark method returns a result.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;while result.status &amp;lt; 4:
    time.sleep(0.2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 10:17:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-export-to-pdf-results/m-p/1005356#M59159</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-11-29T10:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent export to pdf results.</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-export-to-pdf-results/m-p/1006071#M59188</link>
      <description>&lt;P&gt;Thanks David,&lt;/P&gt;&lt;P&gt;I'll give that a try. Appreciate it.&lt;/P&gt;&lt;P&gt;Randy&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 01:25:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-export-to-pdf-results/m-p/1006071#M59188</guid>
      <dc:creator>RandyMcGregor_Home</dc:creator>
      <dc:date>2020-12-02T01:25:10Z</dc:date>
    </item>
  </channel>
</rss>

