Hi everyone,
I am using #Arcgis pro 2.5 and I have an issue 😞
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...
And it work unless I uncomment this line :
cursor = arcpy.da.SearchCursor(layerSet,"*")
Then, the mapframe is empty 😞
But I want to iterate through Row objects and extract field values in my global code !
Any idea ?
import arcpy, os, time
from arcpy import env
# define the project
aprx = arcpy.mp.ArcGISProject("CURRENT")
# Define the first map
m = aprx.listMaps()[0]
# first layer in m
layerSet = m.listLayers()[0]
#cursor = arcpy.da.SearchCursor(layerSet,"*")
# define the first layout
layoutwork = aprx.listLayouts()[0]
# define first mapframe in the layout
mf = layoutwork.listElements("MAPFRAME_ELEMENT")[0]
# list of the bookmarks
bkmks = mf.map.listBookmarks()
#loop of the boukmarks
for bkmk in bkmks:
# zoom to the bookmark
mf.zoomToBookmark(bkmk)
# export in pdf
layoutwork.exportToPDF(os.path.join(r"C:\temp", f"{bkmk.name}.pdf"))