Wednesday 30 August 2017

arcgis 10.3 - Checking .mxd version using ArcPy?


I am looking for a way to check the mxd version of a bunch of mxds. I found a script here at ArcPy method to determine ArcMap document version


I am using ArcGIS 10.3.1 on my desktop.


It goes through the directories and for every mxd it finds it grabs a bunch of details, one of which is the version. My only problem is that sometimes it can not find the version of ArcGIS; it seems to be about 50/50. At first I thought if it didn't return that correct value that meant it was below 10.0. But running my script on 200 mxds it returned the value 9.3 a few times, which means that the ones where it does not return any value could be any version and not just something below 10.0.


The current code taken from the other question:


def getMXDVersion(mxdFile):
matchPattern = re.compile("9.2|9.3|10.0|10.1|10.2|10.3")
with open(mxdFile, 'rb') as mxd:

fileContents = mxd.read().decode('latin1')[1000:4500]
removedChars = [x for x in fileContents if x not in [u'\xff',u'\x00',u'\x01',u'\t']]
joinedChars = ''.join(removedChars)
regexMatch = re.findall(matchPattern, joinedChars)
#print mxdFile
#print joinedChars
#print regexMatch
if len(regexMatch) > 1:
version = regexMatch[len(regexMatch) - 1]
return version

elif len(regexMatch) == 1:
version = regexMatch[0]
return version
else:
return 'version could not be determined for ' + mxdFile

Is there any other way to find the map document's version number?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...