Dear All,
I have a question for exporting bookmarks, This script exports bookmarks from "Vic layout", I wanted to ask, if it is possible, to reference, bookmarks in a different layout/map, and export it. If yes, what should I change in the script. All the bookmarks are in the same project. Dan Patterson Python
Code formatting would help with line numbers
/blogs/dan_patterson/2016/08/14/script-formatting
From ….
ArcGISProject—ArcPy | ArcGIS Desktop
The general syntax (in your case) would be....
for lyt in aprx.listLayouts():
and if you want to export all the bookmarks from all the layouts, then you have to indent your last 3 lines so that they are with the main loop
Hi Dan, Thank you for the quick response. The loop works perfectly for the layout that has the bookmarks, but I want to zoom those same Bookmarks in a different layout.
I have four different layouts (Vic Layout, Zone Layout, Hist Layout, Prep Layout) with different contents (Map Frame Elements).
I created the bookmarks using the map in Vic Layout, but the script currently doesn't allow me to reference these Bookmarks in Zone Layout, Hist Layout, or Prep Layout, it returns an empty out.
So my question is how do I reference or zoom to these bookmarks in Zone Layout, Hist Layout, and Prep Layout in the script, export them.
This code works perfectly:
import arcpy
aprx = arcpy.mp.ArcGISProject(r"Y:\Pro\Research\Books.aprx")
for lyt in aprx.listLayouts("Vic Layout*"):
mf = lyt.listElements("MAPFRAME_ELEMENT")[0]
bkmks = mf.map.listBookmarks()
for bkmk in bkmks:
mf.zoomToBookmark(bkmk)
lyt.exportToJPEG(r"Y:\Pro\Research" + "\\" + bkmk.name)
.. but this doesn't
import arcpy
aprx = arcpy.mp.ArcGISProject(r"Y:\Pro\Research\Books.aprx")
for lyt in aprx.listLayouts("Zone Layout*"):
mf = lyt.listElements("MAPFRAME_ELEMENT")[0]
bkmks = mf.map.listBookmarks()
for bkmk in bkmks:
mf.zoomToBookmark(bkmk)
lyt.exportToJPEG(r"Y:\Pro\Research" + "\\" + bkmk.name)
Sorry for the long response, I wanted to give you detailed context so that you could help me. Thank you so much in advance
Hi Dan Patterson, please I am following up on this issue to see if you've got any update from your end. Thank you in advance.
I was wondering what the ...'but this doesn't ... to be clarified. Did you get an error? Do all your aprx's have a Zone Layout layout in them? or do those change?
Hi Dan, I don't get an error, it returns an empty output since the map frame in the Zone Layout is not the one used to create the bookmarks.
I have only one aprx and with multiple layouts, Zone Layout is one of them, the others are : Vic Layout, Hist Layout, Prep Layout.
I want to able reference the Bookmarks for all the four different layouts, but the bookmarks work only for the layout (Vic Layout) which contains the map frame used to create the Bookmarks.
Thank You.
lost me now... the bookmarks are associated with map frame which is associated with the layout in the aprx, but you are saying that the bookmarks only work for the layout which contains the map frame using to create the bookmarks. AT this point, I would have a look at what you have manually to figure out what you have and what it belongs to