import arcpy, os, sys #Reference current MXD mxd = arcpy.mapping.MapDocument("current") #Reference appropriate data frames currentDF = arcpy.mapping.ListDataFrames(mxd,"Layers")[0] #Reference appropriate tables surveys = arcpy.mapping.ListTableViews(mxd, "Surveys", currentDF)[0] overlap = arcpy.mapping.ListTableViews(mxd, "OriginalSurvey", currentDF)[0] sites = arcpy.mapping.ListTableViews(mxd, "Sites", currentDF)[0] #Reference layout elements by calling ListLayoutElements only once - get better performance for elm in arcpy.mapping.ListLayoutElements(mxd): if elm.name =="text1col1": text1col1 = elm if elm.name =="text1col2": text1col2 = elm if elm.name =="text1col3": text1col3 = elm if elm.name =="text2col1": text2col1 = elm if elm.name =="text3col1": text3col1 = elm #Clear all table text values text1col1.text = " " text1col2.text = " " text1col3.text = " " text2col1.text = " " text3col1.text = " " #I know I probably don't need this: surveytable = surveys overlaptable = overlap sitetable = sites #SURVEYS TABLE: rows = arcpy.SearchCursor(surveytable, "", "", "NMCRIS_NUM; SURVEY_ACRES; TOTAL_ACRES", "NMCRIS_NUM A") if row in rows: for row in rows: text1col1.text = text1col1.text + row.getValue("NMCRIS_NUM") + "\n" text1col2.text = text1col2.text + row.getValue("SURVEY_ACRES") + "\n" text1col3.text = text1col3.text + row.getValue("TOTAL_ACRES") + "\n" if row: del row if rows: del rows #OVERLAP TABLE: rows = arcpy.SearchCursor(overlaptable, "", "", "TOTAL", "") if row in rows: for row in rows: text2col1.text = text2col1.text + row.getValue("TOTAL") + " acres\n" if row: del row if rows: del rows #SITES TABLE: rows = arcpy.SearchCursor(sitetable, "", "", "ARMSARCHID", "") if row in rows: for row in rows: text3col1.text = text3col1.text + "LA " + row.getValue("ARMSARCHID") + "\n" if row: del row if rows: del rows
Solved! Go to Solution.
#SURVEYS: rows = arcpy.SearchCursor(surveys, "", "", "NMCRIS_NUM; SURVEY_ACRES; TOTAL_ACRES", "NMCRIS_NUM A") row = rows.next() while row <> None: text1col1.text = text1col1.text + row.getValue("NMCRIS_NUM") + "\n" text1col2.text = text1col2.text + row.getValue("SURVEY_ACRES") + "\n" text1col3.text = row.getValue("TOTAL_ACRES") row = rows.next() #OVERLAP: rows = arcpy.SearchCursor(overlap, "", "", "TOTAL", "") row = rows.next() while row <> None: text2col1.text = text2col1.text + row.getValue("TOTAL") + " acres\n" row = rows.next() #SITES: rows = arcpy.SearchCursor(sites, "", "", "ARMSARCHID", "ARMSARCHID A") row = rows.next() while row <> None: text3col1.text = text3col1.text + "LA " + row.getValue("ARMSARCHID") + "\n" row = rows.next() if row: del row if rows: del rows #END
#SURVEYS: rows = arcpy.SearchCursor(surveys, "", "", "NMCRIS_NUM; SURVEY_ACRES; TOTAL_ACRES", "NMCRIS_NUM A") row = rows.next() while row <> None: text1col1.text = text1col1.text + row.getValue("NMCRIS_NUM") + "\n" text1col2.text = text1col2.text + row.getValue("SURVEY_ACRES") + "\n" text1col3.text = row.getValue("TOTAL_ACRES") row = rows.next() #OVERLAP: rows = arcpy.SearchCursor(overlap, "", "", "TOTAL", "") row = rows.next() while row <> None: text2col1.text = text2col1.text + row.getValue("TOTAL") + " acres\n" row = rows.next() #SITES: rows = arcpy.SearchCursor(sites, "", "", "ARMSARCHID", "ARMSARCHID A") row = rows.next() while row <> None: text3col1.text = text3col1.text + "LA " + row.getValue("ARMSARCHID") + "\n" row = rows.next() if row: del row if rows: del rows #END