Hi Jeff, I was hoping to use this multiple frame script for my own mapping. I wanted to have different rotation and scale as well for various data frames. Unfortunately my modified script doesn't seem to be working (I'm pretty new to Python). I've posted the question here: https://community.esri.com/thread/255106-customizing-multiple-element-layout-manager
Hopefully you could take a look at it? Thanks very much!
Hello Raphael,
I apologize for the accidental (colon) typo. I should have tested the code first. I believe the issues you are running into has to do with your pdf output file. Because you are iterating through multiple features, you need to build the PDF to uniquely name each file. In the example below, I'm using the features "NAME" property and building the outputpath/filename.
mxd = arcpy.mapping.MapDocument("CURRENT")df = arcpy.mapping.ListDataFrames(mxd)[0]lyr = arcpy.mapping.ListLayers(mxd)[0]rows = arcpy.SearchCursor(lyr.dataSource)for row in rows: newDFext = row.getValue("Shape").extent df.extent = newDFext somepath = "C:/Temp/" + row.getValue("NAME") + ".pdf" arcpy.mapping.ExportToPDF(mxd, somepath)
I tired, but didnt work. Something was wrong, i fixed, line 4, requires no colon : at the end
But still doesnt work. Changes the extent, but doesnt export pdf. What is wrong?
mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] lyr = arcpy.mapping.ListLayers(mxd)[0] rows = arcpy.SearchCursor(lyr.dataSource) for row in rows: newDFExt = row.getValue("Shape").extent df.extent = newDFExt arcpy.mapping.ExportToPDF(mxd, r"D:\TEMP\datadriven") del mxd <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
YES! Thank you. Simple solution.
So I have a DDP mxd with two data frames, one with vector data and the other with imagery and a raster with transparency. I have set the imagery extent to the vector data frame, this works great except when my DDP has rotation angles, the the imagery dataframe does not rotate with the vector data frame. If ESRI could only get the PDF transparency export issue figured out....
mxd = arcpy.mapping.MapDocument("MXD_PATH") frames = arcpy.mapping.ListDataFrames(mxd) for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum ## Sets the rotation angle of the ## dependant data frame to the data ## frame with the DDP index layer, ## assuming it is first in the TOC frames[1].rotation = frames[0].rotation arcpy.mapping.ExportToPDF(mxd, "DOC_NAME"+ str(pageNum) + '.pdf') del mxd
mxd = arcpy.mapping.MapDocument("MXD_PATH") frames = arcpy.mapping.ListDataFrames(mxd) for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum #Sets the rotation angle of the dependant data frame to the data frame with the DDP index layer, assuming it is first in the TOC frames[1].rotation = frames[0].rotation arcpy.mapping.ExportToPDF(mxd, "DOC_NAME"+ str(pageNum) + '.pdf') del mxd
I'm currently working with a customer on this exact issue. They have 320 map sheets. Each sheet can have anywhere from 0 to 6 inset maps. In addition to the insets, they also have 3 tabular reports. Depending on the size and shape of the primary map, all the other items (insets and reports) get placed at different locations. The solution we are building is to store all the page layout info (x,y, width, height, extent, etc) of each element in a table. As we iterate through each map sheet, the appropriate info is read and the appropriate items are positioned.This application will be posted to the Resource Center when complete. We just started so it will take some time.Jeff
Data Driven Pages (DDP) uses one index layer to drive extents. If your two data frames on each page have different extents then I don't think you can do this with only DDP. If both of your data frames have the same extent (but display different layers) you could do this. See the following help topic:http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Customizing_your_map_extent/00s900000011000000/...Jeff
Is there no way to solve that problem whitout a lot of programming?
I looked at your data. If I understand this correctly, you are trying to do something that is a lot more than just setting the extents of 3 data frames.Your upper data frame appears to contain the equivalent of 3 strip map pages, each at a different angle to one another. The data frame below that shows the pipeline running through the 3 pages but it is flattened to run horizontal to the bottom of the page (i.e., profile map).The only way I can think of doing this with Python is to make the middle data frame (and bottom) 3 separate data frames, one for each stripmap page. The trick will be to get the rotation of each stripmap page and then rotate the 3 separate data frames so they are all horizontal to each other. You will also need to calibrate your extents based on the rotation so that you can place each dataframe next to one another to create the appearance of 3 horizontal dataframes that appear a one.I find this interesting but this goes far beyond answering a question about setting data frame extents.The dataframe object allows you to set its extent and also allows you to rotate. I believe this is what you would need to do.Jeff
Let me explain this a little more clearly. In your scenario, you have 2 data frames on a single layout but with different extents. No matter how you address this, you need the equivalent of two index layers; one to drive the first extent, the second to drive the other extent.Your options:1) Use DDP to drive the first extent and arcpy.mapping to drive the second extentor2) Use arcpy.mapping to drive both extents.Below is some sample code that sets the 1st data frame's extent based on each feature extent in the first layer: mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] lyr = arcpy.mapping.ListLayers(mxd)[0] rows = arcpy.SearchCursor(lyr.dataSource): for row in rows: newDFExt = row.getValue("Shape").extent df.extent = newDFExtent arcpy.mapping.ExportToPDF(mxd, somepath) del mxd The logic could be easily extended to multiple data frames.I hope this helps,Jeff
mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] lyr = arcpy.mapping.ListLayers(mxd)[0] rows = arcpy.SearchCursor(lyr.dataSource): for row in rows: newDFExt = row.getValue("Shape").extent df.extent = newDFExtent arcpy.mapping.ExportToPDF(mxd, somepath) del mxd
The solution would need to include arcpy.mapping. Here is a great example in help where two different MXDs are used to handle facing pages (left and right pages use different layout settings). All pages are combined into one fine PDF using arcpy.mapping.http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s90000002p000000.htmJeff
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.