Python Map Page Size

1792
8
03-19-2013 01:13 PM
GregoryElwood1
New Contributor III
Can we set, and change, an .mxd page size using Python?

I've seen several posts that all say no, but am hoping that some adept Python user has figured out how to do this (without using ArcObjects).

We've got some large-size wall maps to make (largest is 96"x54") and would like to make some custom, table-top prints as working maps and for review (20"x20", ANSI-D, etc.). Some of the sizes and layouts may be changed, so being able to automate adding layers to data frames in multiple sizes may prove helpful.

I've looked in to trying to run some trick Data Driven Pages scripts, as in "We're making a map book but every page is a different size and we don't know what all the sizes are going to be, yet" but the Python/page-size issue is kind of a road block.

It seems that using AcroRd32.exe in Python is heading in the right direction, but I'm a novice at Python and could use a code sample if someone has one. Or point me to a Code Gallery that may have one I could look at.

Or...is this something that Python in ArcGIS will never, ever do? (If so, then I'll just go back to defining every page size in an .mxd first and then using srcipting to work with the data frames and layers).

Thanks!

Gregory
Tags (2)
0 Kudos
8 Replies
LucasDanzinger
Esri Frequent Contributor
I think you are kind of limited to the properties and methods available to the MapDocument Class. Unfortunately, pageSize is a read-only property of the MapDocument class, so I don't think you're going to have much luck at this point. Might be worth an enhancement on the ideas page
0 Kudos
GregoryElwood1
New Contributor III
Okay...posted something on the ideas page.

Just to show you how big of a novice I really am, I'm having trouble believing that no one has developed an ArcPy function that defines page size. It just seems so basic to me. I mean, we have functionality for data frames and layers, but nothing in Python that says what physical size of a piece of paper our maps get printed to?

Just me being naive, I guess...

Thanks for your response!

Gregory
0 Kudos
LucasDanzinger
Esri Frequent Contributor
It'll keep growing. When you think about each class, you could probably find 10+ properties that each should have that aren't currently available, and I would say that many of the more common ones will come with time.
0 Kudos
JeffBarrette
Esri Regular Contributor
There is a very long discussion about this but in summary: page size was left read only by design.  Python is NOT designed to be a map document authoring tool.  There are 100's of buttons, properties, context menu items, etc that are not exposed to the Python / arcpy.mapping API.  Python is not a replacement for ArcObjects.

Simply pre-author the mxd(s) with the page sizes you need ahead of time.

Jeff
0 Kudos
markdenil
Occasional Contributor III
The closest you can come is to export a data frame (not a layout) in various formats
and adjust the df_export_height, df_export_width, and resolution arguments.
I agree that this is not much consolation.

As Jeff says above, page size is just not something you can reach using Python alone.
You cannot create data frames, or other entities, using it alone, either.
You can only puppet existing entities about on a pre-defined stage.
0 Kudos
GregoryElwood1
New Contributor III
Jeff,

So, what, if any, is the significance of this thread:

http://forums.arcgis.com/threads/67064-Print-PDFs-with-Python

If Python itself is not meant to be a publishing tool, can it read what a printer (printer driver?) is saying what standard sizes are available and send a data frame with layers to an appropriate page size?

(I hope I'm expressing this correctly)

There's GOT to be a way to use Python to specify page size, even if it has to read it from a printer driver, a library that a user can define or from some other application that Python could potentially recognize. Since I'm still trying to learn this scripting language I'm not adept enough to develop something like this on my own, but I feel very strongly that such method of scripting physical page sizes is possible using Python in ArcGIS. Page size is just too basic of an element of map layout and design to be ignored.

What about something like Chiplotle:

http://music.columbia.edu/cmc/chiplotle/

Or something like an HPGL Plotter emulator in Python?

Sorry I'm being so mule-headed.

Gregory
0 Kudos
JeffBarrette
Esri Regular Contributor
Gregory,

Our fundamental focus with arcpy.mapping is to automate "existing" maps.  If arcpy.mapping could be used to completely author a map from scratch then we would need arcpy to do everything that ArcObjects can do and that would be completely redundant.  Our goal is to keep arcpy.mapping simple and easy to use.

If you could set page size, what would you expect all the existing objects on the layout to do?  Should they automatically resize?  What would happen if the aspect ratios were different?  In ArcMap, if you change page size, your have all the tools at your disposal to make the modifications before printing.

Arcpy.mapping doesn't even allow you to create new objects like data frames and north arrows.  With these two simple examples alone we would need to more than double the API to support all the possible properties you can imagine that exist in these two objects.

This is why we depend on the using the existing ArcMap application to author all this stuff ahead of time and ONLY modify those items that absolutely need to be changed for map automation purposes.

Jeff
0 Kudos
GregoryElwood1
New Contributor III
Jeff,

Thanks for responding to my persistant questioning. I know I'm being a pain.

I have a much better understanding of what arcpy.mapping is meant to do, now.

To answer the direct question about what I would want a page size function to do, the answer is "Yes", all of it. I would want the aspect ration of everything to change if the page size and data frame were to be modified. But I also want to be able to turn that off if I determined I needed it to be. The layers in the TOC (and the scale) should be able to be "locked" even if the data frame aspect ratio and page size were changed. As an end user, flexibility and choice are good.

Part of what has been driving my line of questioning in this thread is the notion that ArcObjects is, in a sense, on the way out. ESRI announcements that VBA will no longer be supported helped to foster this. I wish to embrace Python and ArcPy going forward, and I fully understand your statement about redundancy.

But I also have high standards for ArcGIS in general, I want it to be able to do many things that it currently doesn't do. Especially in term of graphics functionality. Sometimes, I wish ESRI would just get licenses for Adobe Illustrator functions and make them available as an Extension. That would save a lot of us a whole lot of time.

Oh well...can we at least have the ability to create a data frame from scratch in arcpy.mapping? Someday? Maybe...?

Thanks again!

Gregory
0 Kudos