Select to view content in your preferred language

Accessing a Map Documents Bookmarks through Python and ArcPy

5619
12
07-12-2010 03:33 PM
JayDouillard
Emerging Contributor
Is there a way to access the bookmarks within a map document with arcpy? I have a mxd that has several bookmarks, and I'd like to write a script that zooms to the extent of each bookmark, and exports a pdf.
0 Kudos
12 Replies
JeffMoulds
Esri Contributor
Good enhancement. This functionality is not available at 10. However, it is being investigated for a future release - perhaps 10.1. For your records, I will post the NIM tracking number when I have it.
0 Kudos
KimOllivier
Honored Contributor
Meanwhile, someone could help us here. The ESRI help has example scripts in C# and Vb.NET that could be converted to Python using the comtypes module as demonstrated by Mark Cederholm.

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//0001000002w1000000
This could be made into a simple script or module that would do the zooming for us until 10.1 arrives.
An excellent little example of extending ArcPy using ArcObjects.
0 Kudos
JeffMoulds
Esri Contributor
Good enhancement. This functionality is not available at 10. However, it is being investigated for a future release - perhaps 10.1. For your records, I will post the NIM tracking number when I have it.


The tracking number for this enhancement is NIM060058. The plan is to have it in 10.1; however, it is too early to guarantee inclusion at this point.
0 Kudos
AaronPaul
Deactivated User
Has anyone converted Kimos link
http://help.arcgis.com/en/sdk/10.0/a...000002w1000000
To a Python script?

I'm sure many of us can use this conversion.

Thank you, Aaron
0 Kudos
DanielOchoa
Regular Contributor
Jeff,

We are on Arc10 SP2 now and I am not seeing enhancement NIM060058 in the "issues addressed" page:

http://downloads2.esri.com/support/downloads/other_/ArcGIS-10sp2-issues.htm#desktop-sp2

Do you know if this got passed over, or am I just not seeing it, etc....

Thanks,

~ d
0 Kudos
KimOllivier
Honored Contributor
At 10.1 there is a arcpy.mapping.ListBookmarks() function that provides a list of names and extents.
0 Kudos
JeffBarrette
Esri Regular Contributor
Here is a help topic sample.  If you join the beta community you'll be able to try out so much more of the arcpy.mapping functionality that was added at 10.1.

ListBookmarks example 2
Similar to example 1, the following script will loop through each bookmark in the Transportation data frame, set the data frame extent, and export the data frame to a JPEG file.
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0]
for bkmk in arcpy.mapping.ListBookmarks(mxd, data_frame=df):
    df.extent = bkmk.extent
    outFile = r"C:\Project\Output\\" + bkmk.name + ".jpg"
    arcpy.mapping.ExportToJPEG(mxd, outFile, df)
del mxd
0 Kudos
AnneliesBeel
Emerging Contributor
This functionality is great!
Is it also possible to create a polygon shapefile from all the bookmarks in the mxd?
Because I also want a map with the overview, indicating al the "squares" of the different bookmarks.
Does someone know how to do it?

Thanks a lot!!

Here is a help topic sample.  If you join the beta community you'll be able to try out so much more of the arcpy.mapping functionality that was added at 10.1.

ListBookmarks example 2
Similar to example 1, the following script will loop through each bookmark in the Transportation data frame, set the data frame extent, and export the data frame to a JPEG file.
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0]
for bkmk in arcpy.mapping.ListBookmarks(mxd, data_frame=df):
    df.extent = bkmk.extent
    outFile = r"C:\Project\Output\\" + bkmk.name + ".jpg"
    arcpy.mapping.ExportToJPEG(mxd, outFile, df)
del mxd
0 Kudos
AnneliesBeel
Emerging Contributor
Can anyone please help?
Maybe someone from esri? Or should I email the helpdesk?

Thank you!
0 Kudos