AnsweredAssumed Answered

Two data frames with different extents in one layout

Question asked by zerokc on May 23, 2012
Latest reply on Jun 18, 2012 by zerokc
I'm working on a project where I'm trying to print out a series of maps that just follow a power line.  The project will probably end up with about 150 11 x 17 inch maps.  I've placed two data frames, one above the other (landscape) so I can save paper and space.  I've used the strip grid generator for the data driven page to follow and used even/odd pages to drive the data frames.  So far I've been doing what Donna Erskine suggested on this thread (which is talking about the same thing I'm trying to solve).

Jeff Barrette's code suggestions inspired me to attempt to loop the one data frame code into two data frames.  However, this attempt ended in abysmal failure.  Every iteration seemed to confirm my suspicions that I know nothing about arcpy.mapping and data frames.

Here's the code at the point where I gave up:


# Experimental 2 dataframe pdf export  import arcpy from arcpy import env  document = r'C:\Users\Desktop\MapDocuments\Grids Tabloid v1.mxd'  mxd = arcpy.mapping.MapDocument(document) dataframe = arcpy.mapping.ListDataFrames(mxd)  lyr = arcpy.mapping.ListLayers(mxd, "*Grid*")[0] result = arcpy.GetCount_management(lyr) print 'Number of features in ' + str(lyr) + str(result)   print '\nStarting to loop through grids...\n' i = 0 while i < result:     print 'Printing PDF 0' + str(i)     j = 0     for frame in dataframe:         if j == 0:             df = dataframe[j]             print 'Data frame0: ' + str(df)         elif j == 1:             df2 = dataframe[j]             print 'Data frame1: ' + str(df2)         else:             print 'Something\'s wrong'             break                  lyr = arcpy.mapping.ListLayers(mxd, "*Grid*")[j]         print 'Grid layers: ' + str(lyr)         rows = arcpy.SearchCursor(lyr.dataSource)         k = 0         for row in rows:             if k == i and j == 0:                 print 'in df arena'                 newDFExtent = row.getValue("Shape").extent                 df.extent = newDFExtent                 print df.rotation,                 print str([k]) + ' has value from df 1!'             elif k == i and j == 1:                 print 'in df2 arena'                 newDFExtent2 = row.getValue("Shape").extent                 df2.extent = newDFExtent2                 print df2.rotation                 print str([k]) + ' has value from df 2!'             elif k <> i:                 print str([k]) + ' is NO value...'             k += 1         j += 1      arcpy.mapping.ExportToPDF(mxd, r'C:\Users\Desktop\PDFs\TestPDF ' \                               + str(0) + str(i) + '.pdf')     print 'Printed PDF 0' + str(i) + '\n'          i += 1           del mxd


There's a lot of junk code in there so I could tell where the program was, and what it was or wasn't doing.

The psuedo code goes like this:

Find the number of grids in the strip map  Identify the data frames  Break out the layers that have 'grid' in their names  Loop through the grid in the data frame      and set the different extents and rotations for each data driven data frame  Export the page to a PDF  Go to the next page


The PDF output did not display different extents or rotations.  I think from some of the other discussions that 10.1 might provide tools for this.  I'll be done with this project by then.

Any suggestions?

Outcomes