|
POST
|
Can you help me with this please? I am trying to generate a create a folder and the name of this folder would be derived from an attribute value by using the searchCursor and at the same time generate a pdf output which name would also be derived from an attribute valve using the search cursor. This my code below, ive been having serious issues with the folder path as the application claims my output destination does not exist. arcpy.SelectLayerByLocation_management("Parcels", "COMPLETELY_WITHIN", "ClipFeature", "", "NEW_SELECTION")
fc = "Parcels"
field = "LGA"
cursor = arcpy.SearchCursor(fc)
for row in cursor:
row.getValue(field)
val = row.getValue(field)
field = "District"
cursor = arcpy.SearchCursor(fc)
for row in cursor:
row.getValue(field)
val1 = row.getValue(field)
field = "Block_No"
cursor = arcpy.SearchCursor(fc)
for row in cursor:
row.getValue(field)
val2 = row.getValue(field)
field = "Plot_No"
cursor = arcpy.SearchCursor(fc)
for row in cursor:
row.getValue(field)
val3 = row.getValue(field)
outName = str(val) + "LGA"
outName = "Block" + str(val) + "Plot_" + str(val2)
outName1 = "Block_" + str(val2) + "Plot_" + str(val3) + str(val1) + "Area of" + str(val) + "_LGA" + ".pdf"
outName2 = str(val1) + "AREA"
outName3 = "Block" + str(val2) #+ "Plot_" + str(val3)
outName4 = "Plot_" + str(val3)
arcpy.CreateFolder_management("C:\ETE_STATE",outName,outName2,outName3,outName4)
arcpy.mapping.ExportToPDF(mxd,"C:\ETE_STATE", outName+outName2+outName3+outName4+ outName1) Please your suggestions would be appreciated. Thanks (Ive also included my script as an attachment)
... View more
08-25-2012
06:52 PM
|
0
|
0
|
1688
|
|
POST
|
rfairhur24 Thanks for the nugget of information, my question is can you create a custom form using C# and then use python scripts as code behind a button that when clicked would fire some events with a given mxd and return the output? The created custom form would act as a combo box from here a plot would be selected and upon this single selection the events behind the button(python scripts) would act and generate the final output? Thanks
... View more
08-25-2012
06:48 PM
|
0
|
0
|
1688
|
|
POST
|
I am trying to generate a create a folder and the name of this folder would be derived from an attribute value by using the searchCursor and at the same time generate a pdf output which name would also be derived from an attribute valve using the search cursor. This my code below, ive been having serious issues with the folder path as the application claims my output destination does not exist. arcpy.SelectLayerByLocation_management("Parcels", "COMPLETELY_WITHIN", "ClipFeature", "", "NEW_SELECTION")
fc = "Parcels"
field = "LGA"
cursor = arcpy.SearchCursor(fc)
for row in cursor:
row.getValue(field)
val = row.getValue(field)
field = "District"
cursor = arcpy.SearchCursor(fc)
for row in cursor:
row.getValue(field)
val1 = row.getValue(field)
field = "Block_No"
cursor = arcpy.SearchCursor(fc)
for row in cursor:
row.getValue(field)
val2 = row.getValue(field)
field = "Plot_No"
cursor = arcpy.SearchCursor(fc)
for row in cursor:
row.getValue(field)
val3 = row.getValue(field)
outName = str(val) + "LGA"
outName = "Block" + str(val) + "Plot_" + str(val2)
outName1 = "Block_" + str(val2) + "Plot_" + str(val3) + str(val1) + "Area of" + str(val) + "_LGA" + ".pdf"
outName2 = str(val1) + "AREA"
outName3 = "Block" + str(val2) #+ "Plot_" + str(val3)
outName4 = "Plot_" + str(val3)
arcpy.CreateFolder_management("C:\ETE_STATE",outName,outName2,outName3,outName4)
arcpy.mapping.ExportToPDF(mxd,"C:\ETE_STATE", outName+outName2+outName3+outName4+ outName1) Please your suggestions would be appreciated. Thanks (Ive also included my script as an attachment)
... View more
08-25-2012
06:40 PM
|
0
|
7
|
1357
|
|
POST
|
I have issues with dropping my pdf output in the specified destination output folder from my code below, it does create the pdf output though, but never drops it in the specified destination folder 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) Any suggestions? Thanks
... View more
08-24-2012
08:25 PM
|
0
|
0
|
426
|
|
POST
|
There are helpful examples in the help for SearchCursor. 2. For a reason i don't know the script 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") Continues with the buffer process even if the count is o or 1. Do you know why? This shouldn't happen if your indents are correct as above. I would test your script by printing a test message (arcpy.AddMessage("Count is: " + str(count)). The script still continues with the buffer analysis; can you help me with an arcpy script that can end/stop the process if the count condition is true? Thanks for your information on the pdf naming convention.... I got it. Thanks man Thanks
... View more
08-24-2012
03:33 PM
|
0
|
0
|
426
|
|
POST
|
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 script 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") Continues with the buffer process even if the count is o or 1. Do you know why?
... View more
08-24-2012
01:12 PM
|
0
|
0
|
874
|
|
POST
|
Sorry; I fixed the code above. There's an example for getOutput (I spelled it wrong) in the help for the GetCount tool. Thanks curtvprice, you've really helped me. Please can you help me with this? 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. Thanks
... View more
08-24-2012
12:46 PM
|
0
|
0
|
874
|
|
POST
|
Sorry to bother you again i got this error when i tried to run the script after i changed the following 1. arcpy.MakeFeatureLayer("Parcels", "tLyr", '"TDP_Status" = \'GENERATED\'') MakeFeatureLayer_Management 2. count = int(arcpy.GetCount("tLyr").GetOutput(0)) 'GetCount_Management' File "<string>", line 1, in <module>
AttributeError: 'Result' object has no attribute 'GetOutput' Please what do you think
... View more
08-24-2012
12:10 PM
|
0
|
0
|
874
|
|
POST
|
Thanks curtvprice for the nugget of information, please can you help me with this Please 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. This is my small script generatedFieldName = "TDP_Status" rows = arcpy.SearchCursor("Parcels", '"TDP_Status" = \'GENERATED\'') for row in rows: if row.TDP_Status = 'GENERATED' print TDP ALREADY GENERATED else: arcpy.Buffer_analysis ("Parcels", "ClipFeature", "12.5 meters", "FULL", "ROUND", "LIST") Any suggestions?
... View more
08-24-2012
10:48 AM
|
0
|
0
|
874
|
|
POST
|
Thanks curtvprice for the nugget of information, please can you help me with this Please 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. This is my small script generatedFieldName = "TDP_Status" rows = arcpy.SearchCursor("Parcels", '"TDP_Status" = \'GENERATED\'') for row in rows: if row.TDP_Status = 'GENERATED' print TDP ALREADY GENERATED else: arcpy.Buffer_analysis ("Parcels", "ClipFeature", "12.5 meters", "FULL", "ROUND", "LIST") Any suggestions?
... View more
08-24-2012
09:28 AM
|
0
|
0
|
912
|
|
POST
|
curtvprice, i intend to include the time in a field called Time_Generated? import datetime now = datetime.datetime.now() strNow = now.strftime("%d %b %Y %H:%M:%S") Where do i add the field?
... View more
08-24-2012
08:53 AM
|
0
|
0
|
912
|
|
POST
|
Thanks Curtis Price, but please how can i include the current time also. Thanks
... View more
08-24-2012
07:49 AM
|
0
|
0
|
912
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-19-2015 08:49 AM | |
| 1 | 10-15-2013 04:42 AM | |
| 1 | 09-20-2016 03:45 AM | |
| 2 | 09-25-2016 03:50 PM | |
| 1 | 08-25-2012 09:15 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|