Python Arcgis List Iterable Error

المشرف العام

Administrator
طاقم الإدارة
I am attempting to create a map layout with automated text placement and to calculate some of the automated text based on three different inputs either shapefiles or geodatabases. I have the entire script working if the initial file that is read contains one polygon for each of the three different types in the Type field. If any of the polygon types is missing I get the error:

Running script alteration... vsu does not exist row being added block does not exist row being added NonVEG does not exist row being added Percent Alteration Calculation is complete PYTHON ERRORS: Traceback info: File "D:\Templates_Tools\PAC.py", line 129, in blocksum = sum(blocktotal)

Error Info: 'int' object is not iterable

The step before this adds an empty polygon with no geometry to the file to stop this from happening. If I add a polygon by hand using the same process, (no geometry) it works though.

This is some of the code that I am using... I hope I haven't made to many horrible errors.

Cheers,

# Import arcpy module Import arcpy, os, sys from arcpy import SearchCursor, UpdateCursor import traceback from numpy import double from __builtin__ import str projectTitle = arcpy.GetParameterAsText(0) input_Table = arcpy.GetParameterAsText(1) vpPointtable = arcpy.GetParameterAsText(2) vsuTable = arcpy.GetParameterAsText(3) vsunum = arcpy.GetParameterAsText(4) blocks = arcpy.GetParameterAsText(5) vpNumber = arcpy.GetParameterAsText(6) mapSheet = arcpy.GetParameterAsText(7) companyLogo = arcpy.GetParameterAsText(8) mxd = arcpy.mapping.MapDocument("CURRENT") vsuArea = 0 nonVEGArea = 0 nonVEGPercent = 0 proposedBlocks = 0 percentAlteration = 0 vsuTotal = 0 vsuPercent = 0 blocktotal = 0 nonvegTotal = 0 viewPointType = "Government Assigned" latDeg = 0 lonDeg = 0 vsuList = [] blockList = [] nonVeglist = [] vluList = [] vpfields = [] #calculate area's in pixels and output sums into text located above fields = ['TYPE', 'AREA', 'VSU', 'VP'] rows = arcpy.SearchCursor(input_Table) countvsu = 0 countblock = 0 countveg = 0 for row in rows: vsu = row.getValue(fields[0]) if vsu == "VSU": vsuArea = row.getValue(fields[1]) vsuList.append(vsuArea) vsuTotal = vsuList countvsu = countvsu + 1 arcpy.AddMessage("The vsu polygon count is " + str(countvsu)) if vsu == "Block": proposedBlocks = row.getValue(fields[1]) blockList.append(proposedBlocks) blocktotal = blockList countblock = countblock + 1 arcpy.AddMessage("The block polygon count is " + str(countblock)) if vsu == "NonVEG": nonVEGArea = row.getValue(fields[1]) nonVeglist.append(nonVEGArea) nonvegTotal = nonVeglist countveg = countveg + 1 arcpy.AddMessage("The nonveg polygon count is " + str(countveg)) if countvsu
 
أعلى