AnsweredAssumed Answered

I need help with an error message i get while running my script from an addin

Question asked by GISGURU_001 on Feb 14, 2014
Latest reply on Feb 14, 2014 by GISGURU_001
I need help with an error message i get while running my script from an ArcGIS python addin I developed. The script loops through only the 1st row and then stops abruptly and gives the error message further below, see my code below;

mxd = arcpy.mapping.MapDocument("Current")         df = arcpy.mapping.ListDataFrames(mxd)[0]         arcpy.SelectLayerByAttribute_management("GISMainFabric_Parcels", "CLEAR_SELECTION")         arcpy.MakeFeatureLayer_management("GISMainFabric_Parcels", "Temp", '"Plot_Status" = \'LOCATED\'AND "TPlan_Status" = \'NOT GENERATED\'AND "SPlan_Status" = \'SITEPLANGENERATED\'')         fc = "Temp"         field = "OBJECTID"         field1 = "Pan_No"         field2 = "Block_No"         field3 = "Name"         field4 = "SitePlan_Status"         field5 = "LGA"         field6 = "District"         field7 = "StatedLen"         field8 = "Cadzone"         field9 = "TPlan_Status"         rows = arcpy.SearchCursor(fc)         row = rows.next()         while row:             val = row.getValue(field)             val1 = row.getValue(field1)             val2 = row.getValue(field2)             val3 = row.getValue(field3)             val4 = row.getValue(field4)             val5 = row.getValue(field5)             val6 = row.getValue(field6)             val7 = row.getValue(field7)             val8 = row.getValue(field8)             val9 = row.getValue(field9)             whereClause = '"OBJECTID"' + " = '" + str(val) + "'"             whereClause2 = '"Block_No"' + " = '" + str(val2) + "'"             whereClause3 = '"District"' + " = '" + str(val6) + "'"             whereClause4 = '"Cadzone"' + " = '" + str(val8) + "'"             whereClause5 = '"Plan_No"' + " = '" + str(val1) + "'"             outName = str(val5) + "_LGA" + "(" + str(val6) + "_Area" + ")"             outName1 = "Plot_" + str(val1) + "(" "Block_" + str(val2) + ")"             outName2 = str(val3) + " Block_" + str(val2) + "_Plot_" + str(val1) + "_" + str(val6) + "_Area_of_" + str(val5) + "_LGA" + ".pdf"             arcpy.SelectLayerByAttribute_management("Temp", "NEW_SELECTION", whereClause)             arcpy.Buffer_analysis ("Temp", "ClipFeature2", "7 meters", "FULL", "ROUND", "LIST")             mxd = arcpy.mapping.MapDocument("Current")             df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]             lyr=arcpy.mapping.ListLayers(mxd, "ClipFeature2", df)[0]             df.extent = lyr.getExtent(True)             arcpy.RefreshActiveView()             df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]             for df in arcpy.mapping.ListDataFrames(mxd):                 df.rotation = 0                 if val7 <= 80:                         df.scale = 250              lyr = arcpy.mapping.ListLayers(mxd, "LineTableLayoutzz")[0]             tableText = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "TableText")[0]             numRows = int(arcpy.GetCount_management(lyr).getOutput(0))             rowHeight = 0.2                 #fieldNames = ["Sequence", "ParcelPlot", "FromBeacon", "ToBeaconNo", "Length", "Bear"]             fieldNames = ["BEACON_No","DIST_______BEARING"]             numColumns = len(fieldNames)             colWidth = 3.0                 #Build graphic table lines based on upper left coordinate                 #set the proper size of the original, parent line, then clone it and position appropriately                 #upperX = 2.5                 #upperY = 7.0             if df.scale <= 250 and numRows <= 10:                 upperX = 5.0                 upperY = 7.0              elif df.scale <= 250 and numRows > 10:                 upperX = 5.0                 upperY = 8.0             elif df.scale <= 500 and numRows <= 10:                 upperX = 5.0                 upperY = 7.0             elif df.scale <= 500 and numRows > 10:                 upperX = 5.0                 upperY = 8.0             elif df.scale <= 750 and numRows <= 10:                 upperX = 5.0                 upperY = 7.0             elif df.scale <= 750 and numRows > 10:                 upperX = 5.0                 upperY = 8.0             elif df.scale <= 1000 and numRows <= 10:                 upperX = 5.0                 upperY = 7.0             elif df.scale <= 1000 and numRows > 10:                 upperX = 5.0                 upperY = 8.0             elif df.scale <= 1500 and numRows <= 10:                 upperX = 5.0                 upperY = 7.0             elif df.scale <= 1500 and numRows > 10:                 upperX = 5.0                 upperY = 8.0             elif df.scale <= 2000 and numRows <= 10:                 upperX = 5.0                 upperY = 7.0             elif df.scale <= 2000 and numRows > 10:                 upperX = 5.0                 upperY = 8.0              elif df.scale <= 2500 and numRows <= 10:                 upperX = 5.0                 upperY = 7.0             elif df.scale <= 2500 and numRows > 10:                 upperX = 5.0                 upperY = 8.0             elif df.scale <= 5000 and numRows <= 10:                 upperX = 5.0                 upperY = 7.0             elif df.scale <= 5000 and numRows > 10:                 upperX = 5.0                 upperY = 8.0             elif df.scale <= 10000 and numRows <= 10:                 upperX = 5.0                 upperY = 7.0             else:                 if df.scale <= 10000 and numRows > 10:                     upperX = 5.0                     upperY = 8.0                 #Place text column names             tableText.elementPositionX = upperX + 0.05 #slight offset             tableText.elementPositionY = upperY             tableText.text = fieldNames[0]             accumWidth = colWidth             for field in range(1, numColumns):                 newFieldTxt = tableText.clone("_clone")                 newFieldTxt.text = fieldNames[field]                 newFieldTxt.elementPositionX = newFieldTxt.elementPositionX + accumWidth                 accumWidth = accumWidth + colWidth                 #Create text elements based on values from the table             table = arcpy.SearchCursor(lyr.dataSource)             y = upperY - rowHeight             for row in table:                 x = upperX + 0.05 #slight offset                 try:                     for field in fieldNames:                     newCellTxt = tableText.clone("_clone")                     newCellTxt.text = row.getValue(field)                     newCellTxt.elementPositionX = x                     newCellTxt.elementPositionY = y                     accumWidth = accumWidth + colWidth                     x = x + colWidth                  y = y - rowHeight                 except:                   print"Invalid value assignment"             arcpy.CreateFolder_management("C:\\ABU\\",outName)             arcpy.CreateFolder_management("C:\\ABU\\"+ outName,outName1)             arcpy.mapping.ExportToPDF(mxd,r"C:\ABU\\" + outName + "\\" + outName1 + "\\" + "Granted To" + outName2)             strvals = "TDP GENERATED"                 #strvalz = " "             now = datetime.datetime.now()             strNow = now.strftime("%d %b %Y %H:%M:%S")             name = os.environ.get('USERNAME')             Today = str(datetime.date.today())             arcpy.SelectLayerByLocation_management("GISMainFabric_Parcels", "HAVE_THEIR_CENTER_IN", "GISMainFabric_Parcels_Printz", "", "NEW_SELECTION")             arcpy.CalculateField_management("GISMainFabric_Parcels","TDP_Status",'"' + strvals + '"')             arcpy.CalculateField_management("GISMainFabric_Parcels","Time_Generated",'"' + strNow + '"')             arcpy.CalculateField_management("GISMainFabric_Parcels","Generated_By",'"' + name + '"')             arcpy.CalculateField_management("GISMainFabric_Parcels","Date_Generated","'" + Today + "'","PYTHON")             arcpy.SelectLayerByAttribute_management("GISMainFabric_Parcels", "CLEAR_SELECTION")             arcpy.SelectLayerByAttribute_management("Temp", "CLEAR_SELECTION")             mxd = arcpy.mapping.MapDocument("Current")             df3 = arcpy.mapping.ListDataFrames(mxd, "DF3")[0]             for elm in arcpy.mapping.ListLayoutElements(mxd, wildcard="*_clone*"):                 elm.delete()             row = rows.next()


and this is the error message further below;

Traceback (most recent call last):   File "C:\Users\Administrator\AppData\Local\ESRI\Desktop10.1\AssemblyCache\{48ABDA3D-7C57-2D3F-90A6-302D00F4E541}\FCTTDPPlanBatchTool_addin.py", line 32, in onClick     val = row.getValue(field)   File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\arcobjects\arcobjects.py", line 1011, in getValue     return convertArcObjectToPythonObject(self._arc_object.GetValue(*gp_fixargs(args))) RuntimeError: ERROR 999999: Error executing function.


Please what do you think its wrong but I'm suspecting the region that contains the graphic element? Thanks in advance

Outcomes