I have written a python script to batch export several pdfs from a single mxd, switching layers on/off and naming the output pdf based on values supplied by the user in a csv file. We import the required datasets into a template mxd I've set up containing pre-named groups and the company sidebar. The template has a large data frame in the centre of the page for the main data and a smaller "inset map" data frame in the sidebar below the legend to show the datasets' position relative to known geographic locations. The geographic location of the main data frame is shown in this inset map.

The issue we're having is that the first pdf export behaves as expected, but the inset map in the rest of the exports shows a larger "main data frame" extent than it should. I've attached two images to illustrate what we're seeing.

The python script is quite long (as it's part of a larger toolset script), but if you need to see it I can add it (though all it does is read a csv, switch layers on/off and export as pdf - no scaling or moving dataframes).

Do I need to refresh / regenerate some values before each export?

Correctly sized extent in inset map

Extent in inset map is larger despite no change in main data frame extents


I start the process from layout view, but the script automatically switches to data view to turn various layers on/off. The issue was caused by the difference in scale when switching between views (still odd that the map was correct, just not the extent indicator!). I've corrected the issue by noting the scale at the start of the script and forcing the switch back to layout view before exporting.

Not the answer you're looking for? Browse other questions tagged or ask your own question.