Dear GIS community,
I am very much a Python N00b so am in need to your expertise.
Scenario:
I am using data driven pages to export to PDF. Each PDF focuses on a single polygon (in this case a postal zone) along with the relative background map. Of the 18000 polygons, 8000 would best suite a Portrait layout and 10000 would be landscape. The orientation preference is already the the data driven pages index layer. The two mxd's are identical except for their layout.
My Aim:
I am trying to write a python script that would allow me to export a selection of polygons (either by a simple selection or a definition query), using the correct layout. I would be in one of the mxd's when running this script.
So far:
Here is the script I have so far -
# Import arcpy module
import arcpy
#Select Paramaters
Select_Index=arcpy.GetParameterAsText(0)
Select_Portrait_Layout = arcpy.GetParameterAsText(1)
Select_landscape_Layout = arcpy.GetParamterASText(2)
Export_Location = arcpy.GetParamaterAsText(3)
# Local variables:
Input_Feature = Select_Index
Output_Layer = "DDP_Index_Temp"
Select_Portrait_Layout = Select_Portrait_Layout
Select_Index = Select_Index
Select_landscape_Layout = Select_landscape_Layout
Export_Location = Export_Location
mxdport = arcpy.mapping.MapDocument(Select_Portrait_Layout)
mxdland = arcpy.mapping.MapDocument(Select_landscape_Layout)
# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(Input_Feature, Output_Layer, "", "", "OBJECTID OBJECTID VISIBLE NONE;Shape Shape VISIBLE NONE;NAME NAME VISIBLE NONE;AREA_CODE AREA_CODE VISIBLE NONE;DESCRIPTIO DESCRIPTIO VISIBLE NONE;FILE_NAME FILE_NAME VISIBLE NONE;NUMBER NUMBER VISIBLE NONE;NUMBER0 NUMBER0 VISIBLE NONE;POLYGON_ID POLYGON_ID VISIBLE NONE;UNIT_ID UNIT_ID VISIBLE NONE;CODE CODE VISIBLE NONE;HECTARES HECTARES VISIBLE NONE;AREA AREA VISIBLE NONE;TYPE_CODE TYPE_CODE VISIBLE NONE;DESCRIPT0 DESCRIPT0 VISIBLE NONE;TYPE_COD0 TYPE_COD0 VISIBLE NONE;DESCRIPT1 DESCRIPT1 VISIBLE NONE;Shape_Length Shape_Length VISIBLE NONE;Shape_Area Shape_Area VISIBLE NONE;Orientation Orientation VISIBLE NONE")
# Process: Select Portrait
arcpy.SelectLayerByAttribute_management(Output_Layer, "NEW_SELECTION", "\"Orientation\" = 'PORTRAIT'")
#Process: Export Portrait
mxdport.dataDrivenPages.exportToPDF(Export_Location,'SELECTED')
# Process: Select Landscape
arcpy.SelectLayerByAttribute_management(Output_Layer, "NEW_SELECTION", "\"Orientation\" = 'LANDSCAPE'")
#Process: Export Landscape
mxdland.dataDrivenPages.exportToPDF(Export_Location,'SELECTED')
The issue:
Simply put, it doesn't work. I keep getting the error the following error -
[ATTACH=CONFIG]20891[/ATTACH]
For this I am guessing its that i'm trying to export selected but from the wrong feature....??
help
David McDermott