<?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: exportToPDF Mapframe empty in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/exporttopdf-mapframe-empty/m-p/700620#M54282</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I'd probably investigate what the listlayers() is generating by throwing in a print statement.&lt;/P&gt;&lt;P&gt;The cursor should accept a layer object as input, but maybe try layer.dataSource instead (look up the syntax as my capital letters are usually mixed up...).&lt;/P&gt;&lt;P&gt;A final thought is that you may have to specify the dataframe object being passed into listlayers()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Jun 2020 11:31:43 GMT</pubDate>
    <dc:creator>DavidPike</dc:creator>
    <dc:date>2020-06-24T11:31:43Z</dc:date>
    <item>
      <title>exportToPDF Mapframe empty</title>
      <link>https://community.esri.com/t5/python-questions/exporttopdf-mapframe-empty/m-p/700619#M54281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I am using #Arcgis pro 2.5 and I have an issue &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am using the code above with a aprx with a map, a layout and some bookmarks.to export to pdf a layout zooming to differents boukmarks...&lt;/P&gt;&lt;P&gt;And it work unless I uncomment this line :&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #7ec3e6;"&gt;cursor = arcpy.da.SearchCursor(layerSet,"*")&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Then, the mapframe is empty &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But I want to iterate through &lt;SPAN class=""&gt;Row&lt;/SPAN&gt; objects and extract field values in my global code !&lt;/P&gt;&lt;P&gt;Any idea ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;arcpy&lt;SPAN style="color: #ed864a; font-weight: bold;"&gt;, &lt;/SPAN&gt;os&lt;SPAN style="color: #ed864a; font-weight: bold;"&gt;, &lt;/SPAN&gt;time
&lt;SPAN style="color: #cc7832;"&gt;from &lt;/SPAN&gt;arcpy &lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;env

&lt;SPAN style="color: #7ec3e6;"&gt;# define the project
&lt;/SPAN&gt;aprx = arcpy.mp.ArcGISProject(&lt;SPAN style="color: #54b33e;"&gt;"CURRENT"&lt;/SPAN&gt;)

&lt;SPAN style="color: #7ec3e6;"&gt;# Define the first map
&lt;/SPAN&gt;m = aprx.listMaps()[&lt;SPAN style="color: #33ccff; font-weight: bold;"&gt;0&lt;/SPAN&gt;]

&lt;SPAN style="color: #7ec3e6;"&gt;# first layer in m
&lt;/SPAN&gt;layerSet = m.listLayers()[&lt;SPAN style="color: #33ccff; font-weight: bold;"&gt;0&lt;/SPAN&gt;]
&lt;SPAN style="color: #7ec3e6;"&gt;#cursor = arcpy.da.SearchCursor(layerSet,"*")
&lt;/SPAN&gt;&lt;SPAN style="color: #7ec3e6;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #7ec3e6;"&gt;# define the first layout
&lt;/SPAN&gt;layoutwork = aprx.listLayouts()[&lt;SPAN style="color: #33ccff; font-weight: bold;"&gt;0&lt;/SPAN&gt;]

&lt;SPAN style="color: #7ec3e6;"&gt;# define first mapframe in the layout
&lt;/SPAN&gt;mf = layoutwork.listElements(&lt;SPAN style="color: #54b33e;"&gt;"MAPFRAME_ELEMENT"&lt;/SPAN&gt;)[&lt;SPAN style="color: #33ccff; font-weight: bold;"&gt;0&lt;/SPAN&gt;]

&lt;SPAN style="color: #7ec3e6;"&gt;# list of the bookmarks
&lt;/SPAN&gt;bkmks = mf.map.listBookmarks()

&lt;SPAN style="color: #7ec3e6;"&gt;#loop of the boukmarks
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;bkmk &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;bkmks:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #7ec3e6;"&gt;# zoom to the bookmark
&lt;/SPAN&gt;&lt;SPAN style="color: #7ec3e6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;mf.zoomToBookmark(bkmk)
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #7ec3e6;"&gt;# export in pdf
&lt;/SPAN&gt;&lt;SPAN style="color: #7ec3e6;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;layoutwork.exportToPDF(os.path.join(&lt;SPAN style="color: #54b33e;"&gt;r"C:\temp"&lt;/SPAN&gt;&lt;SPAN style="color: #ed864a; font-weight: bold;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #54b33e;"&gt;f"&lt;/SPAN&gt;&lt;SPAN style="color: #ed864a;"&gt;{&lt;/SPAN&gt;bkmk.name&lt;SPAN style="color: #ed864a;"&gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #54b33e;"&gt;.pdf"&lt;/SPAN&gt;))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:29:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporttopdf-mapframe-empty/m-p/700619#M54281</guid>
      <dc:creator>BrunoGranger</dc:creator>
      <dc:date>2021-12-12T05:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: exportToPDF Mapframe empty</title>
      <link>https://community.esri.com/t5/python-questions/exporttopdf-mapframe-empty/m-p/700620#M54282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I'd probably investigate what the listlayers() is generating by throwing in a print statement.&lt;/P&gt;&lt;P&gt;The cursor should accept a layer object as input, but maybe try layer.dataSource instead (look up the syntax as my capital letters are usually mixed up...).&lt;/P&gt;&lt;P&gt;A final thought is that you may have to specify the dataframe object being passed into listlayers()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2020 11:31:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporttopdf-mapframe-empty/m-p/700620#M54282</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-06-24T11:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: exportToPDF Mapframe empty</title>
      <link>https://community.esri.com/t5/python-questions/exporttopdf-mapframe-empty/m-p/700621#M54283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;Thank you for your answer &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;PRE style="background-color: #131314; color: #ebebeb; font-family: 'JetBrains Mono',monospace; font-size: 9,8pt;"&gt;print(layerSet)&lt;/PRE&gt;&lt;P&gt;Return the longName of the first layer ie : sel\Region&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="background-color: #131314; color: #ebebeb; font-family: 'JetBrains Mono',monospace; font-size: 9,8pt;"&gt;print(layerSet.name)&lt;/PRE&gt;&lt;P&gt;Return the 'short' name of the first layer : Region&lt;/P&gt;&lt;PRE style="background-color: #131314; color: #ebebeb; font-family: 'JetBrains Mono',monospace; font-size: 9,8pt;"&gt;cursor = arcpy.da.SearchCursor(layerSet.dataSource&lt;SPAN style="color: #ed864a; font-weight: bold;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #54b33e;"&gt;"*"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;Have the same result : the mapframe is empty &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;How do you do :&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;David Pike a écrit:&lt;/P&gt;&amp;nbsp;specify the dataframe object being passed into listlayers()&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2020 22:13:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporttopdf-mapframe-empty/m-p/700621#M54283</guid>
      <dc:creator>BrunoGranger</dc:creator>
      <dc:date>2020-06-24T22:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: exportToPDF Mapframe empty</title>
      <link>https://community.esri.com/t5/python-questions/exporttopdf-mapframe-empty/m-p/700622#M54284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;oh I thought print(layerSet) would return an Object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What are you intending to do with the cursor and the code in general? I cant see a use of the cursor after it's instantiated. Would give me a better insight when reading the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2020 10:11:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporttopdf-mapframe-empty/m-p/700622#M54284</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-06-25T10:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: exportToPDF Mapframe empty</title>
      <link>https://community.esri.com/t5/python-questions/exporttopdf-mapframe-empty/m-p/700623#M54285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;This is my code :&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;arcpy&lt;SPAN style="color: #ed864a; font-weight: bold;"&gt;, &lt;/SPAN&gt;os

&lt;SPAN style="color: #cc7832;"&gt;from &lt;/SPAN&gt;arcpy &lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;env

&lt;SPAN style="color: #7ec3e6;"&gt;# define the projet
&lt;/SPAN&gt;aprx = arcpy.mp.ArcGISProject(&lt;SPAN style="color: #54b33e;"&gt;"CURRENT"&lt;/SPAN&gt;)

&lt;SPAN style="color: #7ec3e6;"&gt;# Défine the map
&lt;/SPAN&gt;m = aprx.listMaps(&lt;SPAN style="color: #54b33e;"&gt;"Departmental"&lt;/SPAN&gt;)[&lt;SPAN style="color: #33ccff; font-weight: bold;"&gt;0&lt;/SPAN&gt;]

&lt;SPAN style="color: #7ec3e6;"&gt;# define the layout
&lt;/SPAN&gt;layoutwork = aprx.listLayouts(&lt;SPAN style="color: #54b33e;"&gt;"MEP"&lt;/SPAN&gt;)[&lt;SPAN style="color: #33ccff; font-weight: bold;"&gt;0&lt;/SPAN&gt;]
&lt;SPAN style="color: #7ec3e6;"&gt;# define the mapframe
&lt;/SPAN&gt;mf = layoutwork.listElements(&lt;SPAN style="color: #54b33e;"&gt;"MAPFRAME_ELEMENT"&lt;/SPAN&gt;)[&lt;SPAN style="color: #33ccff; font-weight: bold;"&gt;0&lt;/SPAN&gt;]

&lt;SPAN style="color: #7ec3e6;"&gt;# layers list in m(ap)
&lt;/SPAN&gt;layerSets = m.listLayers()
&lt;SPAN style="color: #7ec3e6;"&gt;# Region layout
&lt;/SPAN&gt;layerRegion =  m.listLayers(&lt;SPAN style="color: #54b33e;"&gt;"Region"&lt;/SPAN&gt;)[&lt;SPAN style="color: #33ccff; font-weight: bold;"&gt;0&lt;/SPAN&gt;]

&lt;SPAN style="color: #7ec3e6;"&gt;# Number of row in Region
&lt;/SPAN&gt;result = arcpy.GetCount_management(&lt;SPAN style="color: #54b33e;"&gt;"Sel\Region"&lt;/SPAN&gt;)
nbregion = int(result.getOutput(&lt;SPAN style="color: #33ccff; font-weight: bold;"&gt;0&lt;/SPAN&gt;))
print(&lt;SPAN style="color: #54b33e;"&gt;"nb regions : "&lt;/SPAN&gt;+str(nbregion))

&lt;SPAN style="color: #7ec3e6;"&gt;# Loop Region layer
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;with &lt;/SPAN&gt;arcpy.da.SearchCursor(layerRegion&lt;SPAN style="color: #ed864a; font-weight: bold;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #54b33e;"&gt;'admin1Name'&lt;/SPAN&gt;) &lt;SPAN style="color: #cc7832;"&gt;as &lt;/SPAN&gt;cursor:
    &lt;SPAN style="color: #7ec3e6;"&gt;# for every région
&lt;/SPAN&gt;&lt;SPAN style="color: #7ec3e6;"&gt;    &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;row &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;cursor:
        LaRegion = row[&lt;SPAN style="color: #33ccff; font-weight: bold;"&gt;0&lt;/SPAN&gt;]
        print(&lt;SPAN style="color: #54b33e;"&gt;"--- Création des cartes pour : "&lt;/SPAN&gt;+LaRegion)
        &lt;SPAN style="color: #7ec3e6;"&gt;# find the bookmark of the region
&lt;/SPAN&gt;&lt;SPAN style="color: #7ec3e6;"&gt;        &lt;/SPAN&gt;bkmks = mf.map.listBookmarks()
        &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;bkmk &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;bkmks:
            &lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;bkmk.name == LaRegion:
                mf.zoomToBookmark(bkmk)
        &lt;SPAN style="color: #7ec3e6;"&gt;# loop for every layer in the map
&lt;/SPAN&gt;&lt;SPAN style="color: #7ec3e6;"&gt;        &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;layerSet1 &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;layerSets:
            &lt;SPAN style="color: #7ec3e6;"&gt;# If The layer is in a group and it's not region
&lt;/SPAN&gt;&lt;SPAN style="color: #7ec3e6;"&gt;            &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;layerSet1.name != layerSet1.longName &lt;SPAN style="color: #cc7832;"&gt;and &lt;/SPAN&gt;layerSet1.name != &lt;SPAN style="color: #54b33e;"&gt;"Region"&lt;/SPAN&gt;:
                print(layerSet1.name)
                &lt;SPAN style="color: #7ec3e6;"&gt;# If the layer is gris
&lt;/SPAN&gt;&lt;SPAN style="color: #7ec3e6;"&gt;                &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;layerSet1.name == &lt;SPAN style="color: #54b33e;"&gt;"gris"&lt;/SPAN&gt;:
                    print(&lt;SPAN style="color: #54b33e;"&gt;"yoman------gris"&lt;/SPAN&gt;)
                &lt;SPAN style="color: #7ec3e6;"&gt;# If the layer is not gris
&lt;/SPAN&gt;&lt;SPAN style="color: #7ec3e6;"&gt;                &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;else&lt;/SPAN&gt;:
                    layerSet1.visible = &lt;SPAN style="color: #cc7832;"&gt;True
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;                    &lt;/SPAN&gt;ensDef = &lt;SPAN style="color: #54b33e;"&gt;'"admin1Name" =&lt;/SPAN&gt;&lt;SPAN style="color: #ed864a;"&gt;\'&lt;/SPAN&gt;&lt;SPAN style="color: #54b33e;"&gt;' &lt;/SPAN&gt;+ LaRegion + &lt;SPAN style="color: #54b33e;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="color: #ed864a;"&gt;\'&lt;/SPAN&gt;&lt;SPAN style="color: #54b33e;"&gt;'
&lt;/SPAN&gt;&lt;SPAN style="color: #54b33e;"&gt;                    &lt;/SPAN&gt;layerSet1.definitionQuery = ensDef
                    NomFichier = &lt;SPAN style="color: #54b33e;"&gt;"D:&lt;/SPAN&gt;&lt;SPAN style="color: #ed864a;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #54b33e;"&gt;temp&lt;/SPAN&gt;&lt;SPAN style="color: #ed864a;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #54b33e;"&gt;"&lt;/SPAN&gt;+LaRegion+&lt;SPAN style="color: #54b33e;"&gt;"_"&lt;/SPAN&gt;+layerSet1.name+&lt;SPAN style="color: #54b33e;"&gt;".pdf"
&lt;/SPAN&gt;&lt;SPAN style="color: #54b33e;"&gt;                    &lt;/SPAN&gt;layoutwork.exportToPDF(NomFichier)
                    layerSet1.visible = &lt;SPAN style="color: #cc7832;"&gt;False&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Thank you for your help &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the result :&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/497913_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:29:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporttopdf-mapframe-empty/m-p/700623#M54285</guid>
      <dc:creator>BrunoGranger</dc:creator>
      <dc:date>2021-12-12T05:29:14Z</dc:date>
    </item>
  </channel>
</rss>

