My program works but it is not displaying a message of the total sheet count found in attribute table that the search cursor searched through. For Example: It goes through the mxd chosen by user finds the layer with the name Grid in it and then is supposed to count the rows in the field Sheet_ID. End result is to print a message of the count found. My code is below:
import arcpy, os, sys
from os import path as p
from arcpy import mapping as m
mxdList = arcpy.GetParameterAsText(0).split(';')
sheet_count = ()
for mapDoc in mxdList:
arcpy.AddMessage(mapDoc)
mxd = arcpy.mapping.MapDocument(mapDoc)
for lyr in m.ListLayers(mxd, "*, Grid"):
if lyr.description == "*, Grid":
max_list = []
rows = arcpy.SearchCursor(lyr)
for row in rows:
max_list.append(row.Sheet_ID)
sheet_count = max(max_list)
arcpy.AddMessage('Sheet count: %s'%sheet_count)
print 'Sheet count: %s'%sheet_count
else:
arcpy.AddError('No Layers in %s match data source'%mapDoc)
No comments:
Post a Comment