<?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: Add bookmark(.dat) file to  MXDs using arcpy? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586326#M46023</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;don't go cheap on the print statements...why not add print(bkmk) to see if there are any bookmarks and ... print(str(bkmk.extent)) to see if there is any extent. etc etc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Dec 2015 15:59:13 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2015-12-23T15:59:13Z</dc:date>
    <item>
      <title>Add bookmark(.dat) file to  MXDs using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586325#M46022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; background-color: rgba(248, 248, 248, 0.6);"&gt;Does anyone know any python script to import a bookmark (saved as a .dat) that was created and saved in folder by using arcpy?&amp;nbsp; I tried with this script but without a result- just the name of the projects printed:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env

env.workspace = r"D:\desktop\Project"
for mxdname in arcpy.ListFiles("*.mxd"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print mxdname
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(r"D:\desktop\Project\\" + mxdname)
&amp;nbsp;&amp;nbsp;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; for bkmk in arcpy.mapping.ListBookmarks(mxd, 'Bookmark1', df):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(str(bkmk.extent))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df.extent = bkmk.extent
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()
del mxd&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For clarity, i asked it in &lt;A href="http://gis.stackexchange.com/questions/107035/importing-external-bookmark-dat-files-into-many-mxds-using-arcpy" title="http://gis.stackexchange.com/questions/107035/importing-external-bookmark-dat-files-into-many-mxds-using-arcpy" rel="nofollow noopener noreferrer" target="_blank"&gt;Importing external bookmark (.dat) files into many MXDs using arcpy? - Geographic Information Systems Stack Exchange&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:13:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586325#M46022</guid>
      <dc:creator>Yaron_YosefCohen</dc:creator>
      <dc:date>2021-12-12T01:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Add bookmark(.dat) file to  MXDs using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586326#M46023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;don't go cheap on the print statements...why not add print(bkmk) to see if there are any bookmarks and ... print(str(bkmk.extent)) to see if there is any extent. etc etc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Dec 2015 15:59:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586326#M46023</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-12-23T15:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Add bookmark(.dat) file to  MXDs using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586327#M46024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i did that - noop, it still just printed the mxdname&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Dec 2015 16:31:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586327#M46024</guid>
      <dc:creator>Yaron_YosefCohen</dc:creator>
      <dc:date>2015-12-23T16:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Add bookmark(.dat) file to  MXDs using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586328#M46025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;which means it didn't even get into the bookmark ListBookmarks loop or maybe it didn't even find an appropriate dataframe.... more print statements&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Dec 2015 16:37:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586328#M46025</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-12-23T16:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Add bookmark(.dat) file to  MXDs using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586329#M46026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i will try and let you know- thanks Dan!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Dec 2015 16:43:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586329#M46026</guid>
      <dc:creator>Yaron_YosefCohen</dc:creator>
      <dc:date>2015-12-23T16:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Add bookmark(.dat) file to  MXDs using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586330#M46027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;YYC.&amp;nbsp; Interesting idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although I didn't get to the capture part, I did make a few changes so at least you can print it out. Should be easier to work from this point on&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy&amp;nbsp; 
from arcpy import env&amp;nbsp; 
import os
import csv

#ProjDir = r"C:\_beartest\ArcticWork"
ProjDir = r"D:\desktop\Project"
arcpy.env.workspace = ProjDir
arcpy.env.overwriteOutput = True
outFileCSV = os.path.join(ProjDir, "bkmrkOut") + ".csv"
csvFile = open(outFileCSV, "w") 
csvFile.write("mxd, bmName, minX, minY, maxX, maxY \n")

for mxdname in arcpy.ListFiles("*.mxd"):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print mxdname&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(arcpy.os.path.join(ProjDir, mxdname))
&amp;nbsp;&amp;nbsp;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; bookmarks = arcpy.mapping.ListBookmarks(mxd)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for bmName,bmExtent in bookmarks:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("name): {0}&amp;nbsp; extent: {1}".format(bmName, bmExtent))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; minmax = str(bmExtent).split(" ")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("xmin: {0}, ymin: {1}, xmax: {2}, ymax: {3}".format(minmax[0], minmax[1], minmax[2], minmax[3]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csvFile.write("{0}, {1}, {2}, {3}, {4}, {5} \n".format(mxdname, bmName, minmax[0], minmax[1], minmax[2], minmax[3]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #df.extent = bkmk.extent&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #mxd.save() 
#del mxd

csvFile.close()
print("outFile is closed:&amp;nbsp; " + str(csvFile.closed))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EDITED&lt;/STRONG&gt;: updated my code to write all the bookmarks (mxd name, bookmark name, xmin, ymin, xmax, ymax) to a .csv file.&amp;nbsp;&amp;nbsp; So, still not what you are trying to get at, but might be a helpful utility if trying to standardize bookmarks or read in to another mxd.&amp;nbsp; Something I'll use.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:13:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586330#M46027</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-12T01:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Add bookmark(.dat) file to  MXDs using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586331#M46028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rebecca, i run your code and get:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt;
project.mxd
name): Bookmark 1 [2]&amp;nbsp; extent: 157281.902972993 610080.837486482 158430.021501965 610788.233211336 NaN NaN NaN NaN
xmin: 157281.902972993, ymin: 610080.837486482, xmax: 158430.021501965, ymax: 610788.233211336
outFile is closed:&amp;nbsp; True
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;but the data frame didn't zoomed into the bookmark. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:13:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586331#M46028</guid>
      <dc:creator>Yaron_YosefCohen</dc:creator>
      <dc:date>2021-12-12T01:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Add bookmark(.dat) file to  MXDs using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586332#M46029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;that is because it just "prints" the extent.&amp;nbsp; If you examine the code there is no zoomtoextent function.&amp;nbsp; Read code carefully&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Dec 2015 10:04:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586332#M46029</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-12-27T10:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: Add bookmark(.dat) file to  MXDs using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586333#M46030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Correct. I'm just inventorying the bookmarks in the mxds. I have not tried to add bookmarks or to zoombut I can see an inventory of bookmarks in various map docs as helpful if you want to standardize and/or read them into another mxd. But I haven't reversed the process, and if you read in multiple extents, you would need to know which one you are wanting it to zoom to.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is it you are trying to accomplish? Are you trying make sure the mxd is zoomed to a certain area each time you open it, and to have this preset (i.e. Set and saved in Python before you open the mxd?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you are just want an easy way to zoon to a certain extent with a single click, try setting the extent that the home button zooms too.&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/desktop/latest/map/working-with-arcmap/setting-a-custom-full-extent-for-your-data-frame.htm" title="http://desktop.arcgis.com/en/desktop/latest/map/working-with-arcmap/setting-a-custom-full-extent-for-your-data-frame.htm"&gt;Setting a custom full extent for your data frame—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Dec 2015 14:52:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586333#M46030</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2015-12-27T14:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: Add bookmark(.dat) file to  MXDs using arcpy?</title>
      <link>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586334#M46031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am searching for a way to do something very similar- grab extents of bookmarks created somewhere (initially thought in AGOnline, but I can use MXD too) and then have those extents in a file somewhere so I can use them to append to my webmap URL to use the same web map in multiple iframes. Your code looks like it will give me what I need but I get this error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Runtime error &lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 17, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;IndexError: list index out of range&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I copied your code from here and just added the references to my folder location. I rarely use Python so I am not sure what I am doing wrong. My CSV file does have the headers for &lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;mxd&lt;/TD&gt;&lt;TD&gt; bmName&lt;/TD&gt;&lt;TD&gt; minX&lt;/TD&gt;&lt;TD&gt; minY&lt;/TD&gt;&lt;TD&gt; maxX&lt;/TD&gt;&lt;TD&gt; maxY &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;but no bookmakr data itself&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any ideas? thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Feb 2016 17:12:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-bookmark-dat-file-to-mxds-using-arcpy/m-p/586334#M46031</guid>
      <dc:creator>C_EHoward</dc:creator>
      <dc:date>2016-02-19T17:12:50Z</dc:date>
    </item>
  </channel>
</rss>

