<?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: Deterimine version of MXD from Python? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443014#M14881</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ArcMap v10.0 sp5 does solve this problem.&amp;nbsp; Although you can not determine the version of an mxd in python, python will throw an exception instead of completely crashing if it encounters an ArcMap v10.1 mxd file.&amp;nbsp; So if you are processing a large batch of mxds, you can use try except to catch ArcMap v10.1 files and then move on to the next mxd without processing the file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 31 May 2013 14:46:40 GMT</pubDate>
    <dc:creator>MichaelVolz</dc:creator>
    <dc:date>2013-05-31T14:46:40Z</dc:date>
    <item>
      <title>Deterimine version of MXD from Python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443004#M14871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm using ArcGIS 10.0 and arcpy.mapping.ListLayers to iterate through the layers in a list of MXDs. my problem is that someon has saved a 10.1 mxd somewhere in the list of MXDs I'm working through. I'd be fine with just skipping that file, but how do I determine what version a MXD file is from Python?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Dec 2012 17:09:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443004#M14871</guid>
      <dc:creator>BillWiesepape</dc:creator>
      <dc:date>2012-12-20T17:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Deterimine version of MXD from Python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443005#M14872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm using ArcGIS 10.0 and arcpy.mapping.ListLayers to iterate through the layers in a list of MXDs. my problem is that someon has saved a 10.1 mxd somewhere in the list of MXDs I'm working through. I'd be fine with just skipping that file, but how do I determine what version a MXD file is from Python?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does opening a 10.1 mxd generate an error, as I would expect? In that case the truly Pythonic way is to try it and then ask for forgiveness:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for mxdPath in mxdList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(mxdPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## &amp;lt; do your stuff &amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; except:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Could not open the map document: \"%s\"" % mxdPath
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:49:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443005#M14872</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T19:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: Deterimine version of MXD from Python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443006#M14873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sounded great, until I tried it. Then it didn't work. Below is some sample code. When Python gets to processing the second file it crashes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

pathList = []

pathList.append(r"\\server\share\MyVersion10.mxd")
pathList.append(r"\\server\share\MyVersion10_1.mxd")

for eachPath in pathList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MXD = arcpy.mapping.MapDocument(eachPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for lyr in arcpy.mapping.ListLayers(MXD):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(lyr.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; except:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("failed on " + eachPath)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:49:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443006#M14873</guid>
      <dc:creator>BillWiesepape</dc:creator>
      <dc:date>2021-12-11T19:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Deterimine version of MXD from Python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443007#M14874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Do you know if it crashes when you create a reference to the mxd or when you attempt to list the layers? I find I can get a reference to a 10.1 mxd from 10.0 fine, but then when it try to do stuff it raises exceptions, doesn't explain the crash, but might help us workaround it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 20:19:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443007#M14874</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2012-12-21T20:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Deterimine version of MXD from Python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443008#M14875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris-&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As you describe, it makes connection to the 10.1 MXD just fine, it's once you try to list the layers that the script crashes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 19:24:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443008#M14875</guid>
      <dc:creator>BillWiesepape</dc:creator>
      <dc:date>2012-12-27T19:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Determine version of MXD from Python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443009#M14876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Chris-&lt;BR /&gt;&lt;BR /&gt;As you describe, it makes connection to the 10.1 MXD just fine, it's once you try to list the layers that the script crashes.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please define "crash". Does ArcMap die?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jan 2013 15:42:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443009#M14876</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-01-02T15:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Deterimine version of MXD from Python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443010#M14877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm running the script in IDLE. When it crashes IDLE exits with the message "pythonw.exe has stopped working".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the feeling that the correct answer is "use 10.1" and that will work fine, until 10.2 comes out. There has to be some way to determine if the MXD you are connected to is valid that will at least respect the "try" block instead of completely bombing python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Bill&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jan 2013 17:47:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443010#M14877</guid>
      <dc:creator>BillWiesepape</dc:creator>
      <dc:date>2013-01-02T17:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: Determine version of MXD from Python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443011#M14878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;There has to be some way to determine if the MXD you are connected to is valid that will at least respect the "try" block instead of completely bombing python.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Couldn't agree more. The only other approach I would suggest is quite kludgy - find some content in the 10.1 file that is unique to 10.1, open the file as a string, and look for it. I sure hope Chris or someone else has a better idea!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The better, pythonic solution would be to the mxd object not fail in such an ugly way when it finds unexpected data!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jan 2013 18:58:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443011#M14878</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-01-02T18:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Deterimine version of MXD from Python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443012#M14879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Which service pack of 10.0 do you have installed? I am on service pack 5 and like you I find creating a reference to the MXD is fine, but unlike you an exception is raised when i attempt to list the layers and the try/except succesfully handles it. You may want to try installing sp5 as we may have resolved a bug that resolves this crash. If you are already at sp5 I will have to think about this a little more to come up with an alternative approach.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jan 2013 20:55:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443012#M14879</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2013-01-02T20:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Deterimine version of MXD from Python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443013#M14880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We are SP4. I'll see if we can get the OK to move to SP5 and see if that fixes the problem.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 17:43:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443013#M14880</guid>
      <dc:creator>BillWiesepape</dc:creator>
      <dc:date>2013-01-09T17:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Deterimine version of MXD from Python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443014#M14881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ArcMap v10.0 sp5 does solve this problem.&amp;nbsp; Although you can not determine the version of an mxd in python, python will throw an exception instead of completely crashing if it encounters an ArcMap v10.1 mxd file.&amp;nbsp; So if you are processing a large batch of mxds, you can use try except to catch ArcMap v10.1 files and then move on to the next mxd without processing the file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 May 2013 14:46:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/deterimine-version-of-mxd-from-python/m-p/443014#M14881</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2013-05-31T14:46:40Z</dc:date>
    </item>
  </channel>
</rss>

