MapDocument saveACopy to previous version

5023
17
03-29-2010 10:49 AM
SeanFadum
New Contributor III
Hi,

I have written a small python script to save the ArcGIS 9.4 files I have created back to version 9.3.

The script seems to run fine, but when I try to open the files in Arc 9.3 I get an error message saying the files have been created in a newer version of ArcGIS.  In the help it says if you do not specify a version number that it defaults to an Arc 9.4 file.  Has anyone had success doing this, or is this a bug, or (most likely) am I doing something wrong.  Here is the script:

import arcpy
from arcpy import env
import os
import arcpy.mapping as MAP

env.workspace = "U:\\Projects_VAN\\1961\\0245\\17\\D-Drafting-Design-Analysis\\GIS\\Projects\\mxds"

for file in arcpy.ListFiles("*.mxd"):
   
    mxdFile = os.path.splitext(file)[0] + ".mxd" 

    MXD = MAP.MapDocument("U:\\Projects_VAN\\1961\\0245\\17\\D-Drafting-Design-Analysis\\GIS\\Projects\\mxds\\" + mxdFile)

    MXD.saveACopy("U:\\Projects_VAN\\1961\\0245\\17\\D-Drafting-Design-Analysis\\GIS\\Projects\\mxds\\93\\" + os.path.splitext(file)[0] + "_V_9_3.mxd", '93')
       
print "Files Saved"

Thanks in advance for your help...
0 Kudos
17 Replies
DavidWatkins
Esri Contributor
Does this line need to be '9.3' instead of '93'?

MXD.saveACopy("U:\\Projects_VAN\\1961\\0245\\17\\D-Drafting-Design-Analysis\\GIS\\Projects\\mxds\\93\\" + os.path.splitext(file)[0] + "_V_9_3.mxd", '93')

Not sure if this is why, but have you tried it?
0 Kudos
SeanFadum
New Contributor III
Does this line need to be '9.3' instead of '93'?

MXD.saveACopy("U:\\Projects_VAN\\1961\\0245\\17\\D-Drafting-Design-Analysis\\GIS\\Projects\\mxds\\93\\" + os.path.splitext(file)[0] + "_V_9_3.mxd", '93')

Not sure if this is why, but have you tried it?


I tried it, and python threw the following error:

Invalid value for version: '9.3' (choices are: ['90', '93', '92', '94', '83'])

The help for saveACopy() also says the version needs to be listed as string as one of those 5 versions...

Thanks for the thought but I am still stuck...
0 Kudos
DavidWatkins
Esri Contributor
This appears to be an issue at Beta 2. We have tested this with the pre-release and it is working now.  Another thing to be aware of is that we did make the change at pre-release that requires the dot in the version number, so your script will need to be updated to �??9.3�?? when you get pre-release.  Please get the pre-release when it is available and give it another try and let us know how it goes.
0 Kudos
SeanFadum
New Contributor III
This appears to be an issue at Beta 2. We have tested this with the pre-release and it is working now.  Another thing to be aware of is that we did make the change at pre-release that requires the dot in the version number, so your script will need to be updated to �??9.3�?? when you get pre-release.  Please get the pre-release when it is available and give it another try and let us know how it goes.


Thanks David... will do.
0 Kudos
GünterDörffel
Occasional Contributor III
Hi,

this thread states that in pre-Release the saveACopy works with  the optional second argument of a version number

theMXD.saveACopy(r'c:\temp\mytest.mxd','9.1')
theLYR.saveACopy(r'c:\temp\mytest.lyr','9.3')

I can not confirm this. Regardless of the language settings I use, both produce the same error type:

Runtime error <type 'exceptions.TypeError'>: function takes exactly 1 argument (2 given)

Any other formatting of the second argument (as a floating number, with a different decimal delimiter) produces an error stating

Runtime error <type 'exceptions.ValueError'>: Invalid value for version: 9.0 (choices are: ['10.0', '8.3', '9.0', '9.2', '9.3'])

Is that known?
Regards
Guenter
0 Kudos
JeffBarrette
Esri Regular Contributor
Thanks for reporting this.  There have been several changes to saveACopy and it has been verified that at 10.0 final this does work correctly with recent testing.  There were issues with saving to a previous version, but I don't recall when it was addressed.  The latest version no longer references "94" but rather "10.0".  "93" is now "9.3" in the constants list.

Please try this again with a new 10.0 map document.  Testing on intermediate release MXDs (i.e., beta) may not be a valid test because sometimes the internal content may change.

Thanks,
Jeff
0 Kudos
KathrinJannek
New Contributor
Hi Jeff,
I created a MapDocument with the 10 PreRelease Version and successfully exported it as a 9.3 Version.

>>> mxd = MAP.MapDocument(r'C:\Data\Mxd10.mxd')
>>> mxd.saveACopy(r'C:\Data\Mxd10output.mxd',"9.3")

But, if I try to open the same MapDocument in Desktop 9.3.1, I get following error:

"Opening the selected ArcMap document failed.
An unexpected error occured....
This map document was saved using a newer version of ArcGIS."

In addition I have tried the same steps with a LayerFile, created with the PreRelease (10.0), but I get the same runtime error Guenther has already posted:

>>> layer = MAP.Layer(r'C:\Data\layer10.lyr')
>>> layer.saveACopy(r'C:\Data\layer10test.lyr','9.3')
Runtime error <type 'exceptions.TypeError'>: function takes exactly 1 argument (2 given)

It seems to be a bug in the PreRelease. Could you tell me, if this issue will be solved with the Final Release?

Thanks,
Kathrin
0 Kudos
runegullstrom
New Contributor
Hi,

same problem here. We've got the 10 installed (not prerelease) and when I save the mxd
as 9.3 I can't open them on a desktop running 9.3.

Is this still an issue?

cheers
0 Kudos
JeffBarrette
Esri Regular Contributor
Hello rgullstrom,

We just tried testing this again and can't reproduce.  Is it possible you have a beta MXD that you are trying this with?  If this is a newly created 10.0 final MXD, there may be a layer or layout element that is cauing the problem.  Would it be possible for you to share?  My contact info is jbarrette@esri.com.

Thanks,
Jeff
0 Kudos