row.setvalue(GENERATED, 'GENERATED')
row.GENERATED = 'GENERATED'
fc = "Parcels" field = "Block_No" cursor = arcpy.SearchCursor(fc) for row in cursor: row.getValue(field) val = row.getValue(field) field = "Plot_No" cursor = arcpy.SearchCursor(fc) for row in cursor: row.getValue(field) val2 = row.getValue(field) outName = "Block" + str(val) + "Plot_" + str(val2) outName1 = str(val) + "Plot_" + str(val2) + ".pdf" arcpy.CreateFolder_management("C:\GIS",outName) arcpy.mapping.ExportToPDF(mxd,"C:\GIS\outName\outName1)
There are helpful examples in the help for SearchCursor.2. For a reason i don't know the scriptarcpy.MakeFeatureLayer_management("Parcels", "tLyr", '"TDP_Status" = \'GENERATED\'') count = int(arcpy.GetCount_management("tLyr").getOutput(0)) if count == 0: arcpy.AddMessage("TDP already generated") else: arcpy.Buffer_analysis("Parcels", "ClipFeature", "12.5 meters", "FULL", "ROUND", "LIST")Continues with the buffer process even if the count is o or 1. Do you know why?
arcpy.MakeFeatureLayer_management("Parcels", "tLyr", '"TDP_Status" = \'GENERATED\'') count = int(arcpy.GetCount_management("tLyr").getOutput(0)) if count == 0: arcpy.AddMessage("TDP already generated") else: arcpy.Buffer_analysis("Parcels", "ClipFeature", "12.5 meters", "FULL", "ROUND", "LIST")
For SAG's (American slang), here's the v10.1 equivalent using the new "data access" update cursor syntax:
1. Please can you shed more light on how to extract the value from your table using a cursor (row.getValue) and the conversion, im still a juvenile with arcpy/python.
2. For a reason i don't know the scriptarcpy.MakeFeatureLayer_management("Parcels", "tLyr", '"TDP_Status" = \'GENERATED\'') count = int(arcpy.GetCount_management("tLyr").getOutput(0)) if count == 0: arcpy.AddMessage("TDP already generated") else: arcpy.Buffer_analysis("Parcels", "ClipFeature", "12.5 meters", "FULL", "ROUND", "LIST")Continues with the buffer process even if the count is o or 1. Do you know why?
i want to generate a pdf output by using the arcpy.exporttopdf function, i want the final output to use this nomenclature for naming the pdf output (plot_no.pdf); the plot_no would be derived from an attribute value under the field named plot_no in the attribute table. Please do you have any suggestions.
outName = "plot_" + str(val) + ".pdf"
Sorry; I fixed the code above. There's an example for getOutput (I spelled it wrong) in the help for the GetCount tool.
Sorry to bother you again i got this error
File "<string>", line 1, in <module> AttributeError: 'Result' object has no attribute 'GetOutput'
Thanks curtvprice for the nugget of information, please can you help me with thisPlease can you kindly help with this script also; i am trying to do a search through my attribute table, for a field called TDP_Status and if the attribute is GENERATED, I want the arcpy script to print TDP ALREADY GENERATED and stop the process else it should continue with the buffer analysis.
blocks[/noparse][/post] in your posts - it really helps. No need for a cursor - the GetCount tool is very helpful here. arcpy.MakeFeatureLayer_management("Parcels", "tLyr", '"TDP_Status" = \'GENERATED\'') count = int(arcpy.GetCount_management("tLyr").getOutput(0)) if count == 0: arcpy.AddMessage("TDP already generated") else: arcpy.Buffer_analysis("Parcels", "ClipFeature", "12.5 meters", "FULL", "ROUND", "LIST")
Where do i add the field?
arcpy.AddField("table","TIME_GEN","TEXT","","",20) import datetime now = datetime.datetime.now() strNow = now.strftime("%d %b %Y %H:%M:%S") arcpy.CalculateField_management("table","FIXDATE",'"' + strNow + '"')
Just to debate Curtis' statement about cursors vs. CalculateField...
doesn't the Calc Field tool simply implement a cursor behind the scenes? Why is that inherently faster? Is it because the cursor doesn't have to work through the interpreter?
how can i include the current time also.
import datetime now = datetime.datetime.now() strNow = now.strftime("%d %b %Y %H:%M:%S")
myField = "Date_Gener">>> rows = arcpy.UpdateCursor("Parcels")>>> for row in rows:... row.setValue(myField,'Date ( )') ... rows.updateRow(row)...
import datetime Today = str(datetime.date.today()) arcpy.CalculateField_management("Parcels","date_Gener","'" + Today + "'","PYTHON")
rows = arcpy.UpdateCursor("Parcels", "FID = 1") for row in rows: row.GENERATED = "GENERATED" rows.updateRow(row)
myField = "GENERATED" rows = arcpy.UpdateCursor("Parcels", "FID = 1") for row in rows: row.setValue(myField,"GENERATED") rows.updateRow(row)
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.