mxd.saveACopy changes layout to portrait

1535
9
03-12-2013 12:12 PM
GarethMann
New Contributor III
I have developed a script that loops through all MXDs in a given directory, stores relative paths and then saves it as ArcGIS 9.x compatible.

At firts I thought it was working as expected. But I just opened one of the copied MXDs and it has reset the page layout to portrait 8.5 x 11. The original file was landscape 13 x 8.5.

Any idea why it did this and how I could modify the code to insure that the layout information is preserved in the resulting copy?

Here is my code:


import arcpy, os
def prinnames(sPath):
 folderPath = sPath
      for filename in os.listdir(folderPath):
   fullpath = os.path.join(folderPath, filename)
   if os.path.isfile(fullpath):
    basename, extension = os.path.splitext(fullpath)
    if extension.lower() == ".mxd":
     mxd = arcpy.mapping.MapDocument(fullpath)
    print(basename + "v9")
    mxd.relativePaths = 'True'
     mxd.saveACopy(basename + "v9.mxd","9.0")
  else:
   
   prinnames(fullpath)

prinnames('C:\Gareth\cityWork\CAPERMaps')

Tags (2)
0 Kudos
9 Replies
LindseyWood
New Contributor III
I have used the arcpy.mapping module quite a bit and do not recall being able to set the layout... you can adjust the size though except you would need to bring in your layers etc again..... maybe this will help or maybe there still is not an easy answer to this one.... Perhaps on the next version?

http://gis.stackexchange.com/questions/1535/how-to-change-the-page-layout-from-portrait-to-landscape...

good luck it would be a nice feature to have.
0 Kudos
GarethMann
New Contributor III
Hey lmwood,

That is not actually what I was asking. I was asking why the saveACopy function was not preserving the information about the layout.

This does not appear to be a compatibility issue with 9.x because when I use the regular ArcMap interface to save it as 9.x. the correct layout information does get preserved with the save.
0 Kudos
LindseyWood
New Contributor III
0 Kudos
GarethMann
New Contributor III
Thats for that. That does seem to be a very similar issue.

The problem is basically that when I call the saveACopy function it is ticking the box in the page set-up menu that says "use printer paper settings". And that is why everything is getting resized, if I can somehow tell it to not tick that box then it should not just my layout.....
0 Kudos
GarethMann
New Contributor III
Wow, i have actually found a solution!

If I set mxd.activeView = 'Layers' right before I save it then it will not set it to use the prinetr paper settings.

This solution will work as long as none of my MXDs have the default data frame renamed to something else other than "layers".
0 Kudos
JeffBarrette
Esri Regular Contributor
Are you saying that the original MXD does not have "use printer settings" checked on but when you call .saveACopy via arcpy.mapping and save the result out to a 9.3 doc, that setting somehow gets automatically checked and the output then uses those printer page sizes?

Are all the original MXDs 9.3?  Are any of the MXDs 10x?  Do you have the same issue?

Thanks,
Jeff
0 Kudos
GarethMann
New Contributor III
Jeff,

I am using ArcView 10.1, the mxds I am changing are a variety of mxds made throughtout the period of 2009-2013. Some of them may have been created in versions of ArcMap as old as 9.1.


Are you saying that the original MXD does not have "use printer settings" checked on but when you call .saveACopy via arcpy.mapping and save the result out to a 9.3 doc, that setting somehow gets automatically checked and the output then uses those printer page sizes?


Yes, that is more or less exactly what I am saying, except that I am saving them as version 9.0/9.1 compatible.

The solution was to set the active view to data view before saving them and that appears to alleviate the problem.
0 Kudos
JasonHarshman
Occasional Contributor
We just experienced the same problem when running a script that changes some text in multiple mxd's and then saves them. All the figures are 11x17 landscape, but the script will change the page settings to 8.5x11.
0 Kudos
BrianCunningham2
New Contributor III

Talk about bringing up a discussion from the dead....

We just noticed this same issue with several mxds.  We recently migrated to a new SQL server, and we ran a script to change the source for all of our old project files.

We are noticing that in MXDs where we have multiple data frames we are seeing this issue where the "Use Printer Paper Settings" option gets checked when using the mxd.save() function in Python.

Not much to do about it at this point, but I figured that I'd make a note and bring this back from the dead to see if anyone else is still seeing the same behavior

0 Kudos