AnsweredAssumed Answered

'Cursor' object has no attribute 'getValue'

Question asked by dbannon22trial on May 18, 2012
Latest reply on May 31, 2012 by nahmed-esristaff
I am trying to select an attribute value from one of my tables. Its does not seam to be working. It keeps giving me this error.

Runtime error <type 'exceptions.AttributeError'>: 'Cursor' object has no attribute 'getValue'

>>> mxd = arcpy.mapping.MapDocument("CURRENT") #defines the variable mxd to the current map>>>
... #sets the current author of the mxd to Derek Bannon
... mxd.author = "Derek Bannon"
... #defines the variable df to the one and only dataframe
... df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
... textnumb = 0 #defines varaible textnumb to equal 0
... indexnumb = 295
... #defines the variable PDFdoc to save a blank pdf in memory for the appending pdf files
... PDFdoc = arcpy.mapping.PDFDocumentCreate(r"\\swg.ca\files\Jobs\35000\35628 ED41 Kinder Morgan Canada Inc\500CAD\GIS\MapOutput\PDFOutput\TMX-Parcels-Mapbook.pdf")
... #opens a loop that runs and assigns i to a new value in a range that counts from 3 to 233 #but not including 233 in increments of 3
... for i in range (296, 356,1):
... #defines an if statement where if i is greater than 10 then the operation will break from #the loop and execute a PDF document save and close
... if i > 297:
... #breaks the loop if i is equal to greater than 10
... break
... #saves and close the PDF document created before the loop
... PDFdoc.saveAndClose()
... #this is the else statement that operates when the break statement has not yet been achieved
... else:
... #defines variable j as equaling to i minus 3. Defines the kp range that the map will zoom to
... j=i-3
... #defines the variable textnumb which assigns each map through the loop an incremented number #starting at 1 and counting up
... textnumb=textnumb + 1
... indexnumb=indexnumb + 1
... #defines the variable where_clause for the Select Layer by Attribute tool
... where_clause = "\"PageNumber\" = " + str(i)
... #runs the select layer by attribute tool selecting from the layer 'Kilometer Posts', a new #selection and using the where_clause variable for the selection criteria
... arcpy.SelectLayerByAttribute_management("TMPL_BC_IndexFile","NEW_SELECTION",where_clause)
... #defines the variable where_clause_add for the Select Layer by Attribute tool
... #where_clause_add = "\"KP\" = " + str(i)
... #runs the select layer by attribute tool selecting from the layer 'Kilometer Posts', a new #selection and using the where_clause_add variable for the selection criteria
... #arcpy.SelectLayerByAttribute_management("Kilometer Posts","ADD_TO_SELECTION",where_clause_add)
... #refreshes the Table of Contents
... arcpy.RefreshTOC
... #refreshes the active view
... arcpy.RefreshActiveView
... cursor = arcpy.SearchCursor("TMPL_BC_IndexFile", where_clause) <<<<< something to do with this code here I think.
... rotation = cursor.getValue("Angle")
...
...
...
... df.rotation(rotation)
... #zooms the dataframe to the selected features
... df.zoomToSelectedFeatures()
...
... arcpy.SelectLayerByAttribute_management("TMPL_BC_IndexFile","CLEAR_SELECTION",where_clause)
... dfAsFeature = arcpy.Polygon(arcpy.Array([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]),df.spatialReference)
...
... #arcpy.SelectLayerByLocation_management("Annotations\Sectiontest4","COMPLETELY_WITHIN", dfAsFeature, "","NEW_SELECTION")
... #arcpy.SelectLayerByLocation_management("Annotations\Sectiontest3","COMPLETELY_WITHIN", dfAsFeature, "","ADD_TO_SELECTION")
... #arcpy.SelectLayerByLocation_management("Annotations\Sectiontest2","COMPLETELY_WITHIN", dfAsFeature, "","ADD_TO_SELECTION")
... arcpy.SelectLayerByLocation_management("Annotations\BCParcelsAnno4","COMPLETELY_WITHIN", dfAsFeature, "","ADD_TO_SELECTION")
... #arcpy.CalculateField_management("Annotations\Sectiontest4","Status",0,"VB")
... #arcpy.CalculateField_management("Annotations\Sectiontest3","Status",0,"VB")
... #arcpy.CalculateField_management("Annotations\Sectiontest2","Status",0,"VB")
... arcpy.CalculateField_management("Annotations\BCParcelsAnno4","Status",0,"VB")
... arcpy.SelectLayerByAttribute_management("Annotations\BCParcelsAnno4","CLEAR_SELECTION","")
...
... #arcpy.SelectLayerByAttribute_management("Annotations\Sectiontest2","CLEAR_SELECTION","")
... #arcpy.SelectLayerByAttribute_management("Annotations\Sectiontest3","CLEAR_SELECTION","")
... #arcpy.SelectLayerByAttribute_management("Annotations\Sectiontest4","CLEAR_SELECTION","")
... #arcpy.SelectLayerByLocation_management("Annotations\Sectiontest4","CROSSED_BY_THE_OUTLINE_OF", dfAsFeature, "","NEW_SELECTION")
... #arcpy.SelectLayerByLocation_management("Annotations\Sectiontest3","CROSSED_BY_THE_OUTLINE_OF", dfAsFeature, "","ADD_TO_SELECTION")
... #arcpy.SelectLayerByLocation_management("Annotations\Sectiontest2","CROSSED_BY_THE_OUTLINE_OF", dfAsFeature, "","ADD_TO_SELECTION")
... arcpy.SelectLayerByLocation_management("Annotations\BCParcelsAnno4","CROSSED_BY_THE_OUTLINE_OF", dfAsFeature, "","ADD_TO_SELECTION")
... arcpy.CalculateField_management("Annotations\BCParcelsAnno4","Status",1,"VB")
... #arcpy.CalculateField_management("Annotations\Sectiontest2","Status",1,"VB")
... #arcpy.CalculateField_management("Annotations\Sectiontest3","Status",1,"VB")
... #arcpy.CalculateField_management("Annotations\Sectiontest4","Status",1,"VB")
... arcpy.SelectLayerByAttribute_management("Annotations\BCParcelsAnno4","CLEAR_SELECTION","")
... #arcpy.SelectLayerByAttribute_management("Annotations\Sectiontest2","CLEAR_SELECTION","")
... #arcpy.SelectLayerByAttribute_management("Annotations\Sectiontest3","CLEAR_SELECTION","")
... #arcpy.SelectLayerByAttribute_management("Annotations\Sectiontest4","CLEAR_SELECTION","")
... #clears the current selection for pdf print
... arcpy.SelectLayerByAttribute_management("Kilometer Posts","CLEAR_SELECTION",where_clause_add)
... #refreshes the active view
... arcpy.RefreshActiveView
... #defines the variable textelement to a piece of text within the layout, which us the map #number
... #textElement = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","mapnumber")[0]
... #changes the text from 00 to 00 plus the variable textnumb
... #textElement.text = "00"+str(textnumb)
... #defines the variable textElementkpfrom which is for the kp from label in the layout
... #textElementkpfrom = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","backkp")[0]
... #changes the text in the kp from element to equal to the variable j
... #textElementkpfrom.text = j
... #defines the variable textElementkpto which is the kp to text piece in the layout
... #textElementkpto = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","frontkp")[0]
... #changes the kp to text element to equal the variable i
... #textElementkpto.text = i
... #defines the variable mxdaltname
... #mxdaltname = "TMX-Parcels-Map"+str(i)+".mxd"
... #saves a the current map to an mxd referencing the variable mxdaltname as the filename
... #mxd.saveACopy(r"\\swg.ca\files\Jobs\35000\35628 ED41 Kinder Morgan Canada Inc\500CAD\GIS\MapOutput\\"+mxdaltname)
... #defines the variable pdfname
... pdfname = "TMX-Parcels-Map"+str(i)+".pdf"
... #export the current map to pdf format using pdfname variable as the filename
... arcpy.mapping.ExportToPDF(mxd,r"\\swg.ca\files\Jobs\35000\35628 ED41 Kinder Morgan Canada Inc\500CAD\GIS\MapOutput\PDFOutput\\"+pdfname)
... #appends the created pdf pages to the PDFdoc that was assigned before the loop
... PDFdoc.appendPages(r"\\swg.ca\files\Jobs\35000\35628 ED41 Kinder Morgan Canada Inc\500CAD\GIS\MapOutput\PDFOutput\\"+pdfname)
...
...


Any help much appreciated.

Outcomes