mxd = arcpy.mapping.MapDocument("M:\\par-prod\\checking\\bookmaps.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Legal")[0] make query from list select by attribute(query) for row in cursor: shape=row.shape extent=shape.extent df.extent=extent export
import arcpy, re mxd = arcpy.mapping.MapDocument("M:\\par-prod\\checking\\legal.mxd") dfSection = arcpy.mapping.ListDataFrames(mxd, "Legal")[0]#Shows one section dfTownship = arcpy.mapping.ListDataFrames(mxd, "section")[0]#Shows one township dfCounty = arcpy.mapping.ListDataFrames(mxd, "township")[0] #Shows whole county lyrSection = arcpy.mapping.ListLayers(mxd, "GCDB*", dfSection)[0]#For showing one section lyrTownship = arcpy.mapping.ListLayers(mxd, "GCDB*", dfTownship)[0]#For showing one township data_file = open('todo.txt', 'r') for item in data_file: match=re.search(r'(\d*\D)(\d*\D)(\d*)',item) #splits 2S24E16 into '2S' '24E' '16' in a match object to use Town,Range,Sec=match.group(1),match.group(2),match.group(3) #sets the three parts just collected to variables arcpy.SelectLayerByAttribute_management(lyrTownship, "NEW_SELECTION", "TOWN LIKE '%s%s'"%(Town,Range)) dfTownship.zoomToSelectedFeatures() arcpy.SelectLayerByAttribute_management(lyrSection, "NEW_SELECTION", "TOWN = '%s%s%s'"%(Town,Range,Sec)) dfSection.zoomToSelectedFeatures() arcpy.RefreshActiveView() for elm in arcpy.mapping.ListLayoutElements(mxd, "Text_Element"): if elm.name == "Date": elm.text = 'Date: <dyn type="date" format="short"/>' if elm.name == "Location": elm.text = "SEC %s, T%sR%s"%(Sec,Town,Range) arcpy.mapping.PrintMap(mxd) mxd.save
Well, at least I can say that I was getting there. Works great. I never heard about that "re" module before. I am also aware of the Extent Indicator, but for some reason, it will not highlight the appropriate section on the printed maps. I can't figure out why. If I do everything manually (setting up the indicator, zooming to another section) in ArcMap, it works fine and highlights the section just by zooming to the dfSection. It just won't highlight in the script. Everything in your script works though, and I am very happy that it is printing every map in the list correctly now. Do you have a reason why it was only printing the last item on the list correctly? I guess, I still don't see why it is working versus before. Is is because of that "re" module. Thanks for the help. I really appreciate it.
Sorry for the indenting thing. I guess I didn't quite understand the use of Code(). I think you still can understand it. Thanks againI should mention that I am running this in PythonWIN. I prefer that over running it in ArcMap.
code goes in between these two wrappers
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.