Automated map export, iterating layers and editing text

المشرف العام

Administrator
طاقم الإدارة
So just a beginner here. I've been automating a few map exports with ArcMap, I've used stack exchange to mash together some scripts to export maps with one FC symbolised using different fields and changing the text to field.name. So a big thanks to Stack Exchange

Now I have multiple layers and a look up table and am trying to automate the export again.So I got this which is working, iterating the layers and the field name, BUT the field name is out of sync! Seems the text isn't changing until AFTER export is there something wrong with my indentation or ordering of lines? What else could I have done wrong here?

>>>import arcpy, string, os... mxd = arcpy.mapping.MapDocument("CURRENT")
... df = arcpy.mapping.ListDataFrames(mxd, '')[0] ... TextBOX = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "Description")[0]
... # loop/iterate layers to turn on, text edit command... for lyr in arcpy.mapping.ListLayers(mxd, "Density*CHA", df):... TextBOX.text = x... lyr.visible = True... arcpy.RefreshActiveView()... # use cursor to ... with arcpy.da.SearchCursor("DensityLabels_Table", ['Layer', 'Text']) as cursor1:... for row1 in cursor1:... if lyr.name == row1[0]:... x = row1[1]
... # export and turn off
... arcpy.mapping.ExportToJPEG(mxd, "F://Export_Maps//Density//" + lyr.name + ".jpg")... lyr.visible = False`

The working code, should anyone else have the same problem and have trouble finding the other relevant posts.

import arcpy, string, osmxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, '')[0] #TextBOX = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "Description")[0] #for lyr in arcpy.mapping.ListLayers(mxd, "Density*TOR", df):# with arcpy.da.SearchCursor("DensityLabels_Table", ['Layer', 'Text', 'Suburb']) as cursor1: for row1 in cursor1: if lyr.name == row1[0]: lyr.visible = True TextBOX.text = row1[1] arcpy.RefreshActiveView() arcpy.mapping.ExportToJPEG(mxd, "F://Export_Maps//Density//" + lyr.name + ".jpg") lyr.visible = False`



أكثر...
 
أعلى