import arcpy from arcpy import analysis, env, management workspace = arcpy.env.workspace = "Y:/Office2/WDIA Mapping/April/Scratch.gdb" #fill in the path for the workspace env.overwriteOutput = True mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] distRows = arcpy.SearchCursor('us_house') #sets the search cursor. This may be the problem? #Try an update cursor to resolve looping problem? for row in distRows: distName = row.getValue("NAMELSAD") df.extent = row.SHAPE.extent df.scale = df.scale * 1.07 unique_name = arcpy.CreateUniqueName(distName) whereClause = "NAMELSAD <> '%s'" % distName #this results in the shadow selected_dist = analysis.Select(distName, unique_name, whereClause) #shadow applied to layer layerList = arcpy.mapping.ListLayers(mxd, "", df) #apply the symbology to the currentShadow layer arcpy.ApplySymbologyFromLayer_management (layerList[0], 'usHouseDist_05_shadow') title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "*")[0] title.text = "trial run" #this is where we need to format the title so it can be dymanyic arcpy.mapping.ExportToPDF(mxd, "Y:/Office2/WDIA Mapping/April/firstTrial/district_'%s'" % distName) #remember to fix this line arcpy.mapping.RemoveLayer(df, layerList[0]) del distName, unique_name distRows.next() #arcpy.RefreshActiveView()
Solved! Go to Solution.
import arcpy arcpy.env.overwriteOutput = True mxd = arcpy.mapping.MapDocument(r"U:\Projects\Polygons\Polygons.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] layer = arcpy.mapping.ListLayers(mxd, "Polygons")[0] sc = set(r[0] for r in arcpy.da.SearchCursor(layer, "Field1")) for s in sc: where_clause = "Field1 = '"+s+"'" layer.definitionQuery = where_clause title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT")[0] title.title = s ext = layer.getExtent() df.extent = ext arcpy.AddMessage("Making H:/TestExports/FD" + s + ".pdf") arcpy.mapping.ExportToPDF(mxd, "H:/TestExports/FD" + s + ".pdf") del mxd, df, layer, sc, simport arcpy
from arcpy import analysis, env, management
workspace = arcpy.env.workspace = "Y:/Office2/WDIA Mapping/April/Scratch.gdb" #fill in the path for the workspace
env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
distRows = arcpy.SearchCursor('us_house') #sets the search cursor. This may be the problem?
#Try an update cursor to resolve looping problem?
for row in distRows:
distName = row.getValue("NAMELSAD")
df.extent = row.SHAPE.extent
df.scale = df.scale * 1.07
unique_name = arcpy.CreateUniqueName(distName)
whereClause = "NAMELSAD <> '%s'" % distName #this results in the shadow
selected_dist = analysis.Select(distName, unique_name, whereClause) #shadow applied to this layer
layerList = arcpy.mapping.ListLayers(mxd, "", df)
#apply the symbology to the currentShadow layer
arcpy.ApplySymbologyFromLayer_management (layerList[0], 'usHouseDist_05_shadow') #whatever the top layer is
title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "*")[0]
title.text = "trial run" #this is where we need to format the title so it can be dymanyic
arcpy.mapping.ExportToPDF(mxd, "Y:/Office2/WDIA Mapping/April/firstTrial/district_'%s'" % distName) #remember to fix this line
arcpy.mapping.RemoveLayer(df, layerList[0])
del distName, unique_name
distRows.next()
#arcpy.RefreshActiveView()
import arcpy arcpy.env.overwriteOutput = True mxd = arcpy.mapping.MapDocument(r"U:\Projects\Polygons\Polygons.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] layer = arcpy.mapping.ListLayers(mxd, "Polygons")[0] sc = set(r[0] for r in arcpy.da.SearchCursor(layer, "Field1")) for s in sc: where_clause = "Field1 = '"+s+"'" layer.definitionQuery = where_clause title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT")[0] title.title = s ext = layer.getExtent() df.extent = ext arcpy.AddMessage("Making H:/TestExports/FD" + s + ".pdf") arcpy.mapping.ExportToPDF(mxd, "H:/TestExports/FD" + s + ".pdf") del mxd, df, layer, sc, s