|
POST
|
There may be a better way, but here's the best solution I could find. curs = arcpy.SearchCursor(table) for row in curs: listing.append(row.min_value) print min((abs(0 - i), i) for i in listing)[1] You could also pass the OID or some other identifier to go back to the row object.
... View more
08-08-2012
09:16 AM
|
0
|
0
|
1305
|
|
POST
|
To get a list of sde instances you could do something like this. Not sure if there is a better way.
sde_dir = os.path.join(os.getenv("APPDATA"), r"ESRI\Desktop10.0\ArcCatalog")
sde_list = os.listdir(sde_dir)
if sde.endswith(".sde"):
print sde
... View more
08-08-2012
07:47 AM
|
0
|
0
|
2693
|
|
POST
|
Please read this. http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code As to your problem. What are your field names and types?
... View more
08-07-2012
12:10 PM
|
0
|
0
|
1132
|
|
POST
|
Ensure your script only uses UNC paths not mapped drives, the account you are executing the task as has permissions to access an ArcGIS license and your sde connection file is not using OS authentication.
... View more
08-07-2012
08:29 AM
|
0
|
0
|
1470
|
|
POST
|
Put some print statements in to check what it is doing, if it enters your loop with the expected arguments etc.
... View more
08-02-2012
12:40 PM
|
0
|
0
|
1607
|
|
POST
|
Try removing the trailing forward slash. It works fine for me using ArcGIS 10.0 either way though. I'm not even sure why this needs to be part of the arcpy package though, as tlomiej1 said os.makedirs or os.mkdir are already available.
... View more
08-02-2012
05:36 AM
|
0
|
0
|
2186
|
|
POST
|
As a side note, I'd also look at using UNC paths vs mapped drives for network resources.
... View more
08-02-2012
05:28 AM
|
0
|
0
|
2104
|
|
POST
|
I would suggest creating a tableview or permanent table depending on what you want to do with the data, and using a search cursor on that.
... View more
08-01-2012
12:51 PM
|
0
|
0
|
1656
|
|
POST
|
your syntax for the cursor is a little off. The first parameter is the input which is correct, but the second parameter is the where clause which you have populated with your field variable. Also, you don't need to add the next row commands. You want it to look like this. import arcpy
import os
featureClass = arcpy.GetParameterAsText(0)
photo_field = "PhotoHotlink"
results_field = "PhotoExists"
curs = arcpy.UpdateCursor(featureClass, "", "", [photo_field, results_field])
#row = curs.next()
for row in curs:
photo_path = row.getValue(photo_field)
if os.path.exists(photo_path):
row.setValue(results_field, "Y")
else:
row.setValue(results_field, "N")
curs.updateRow(row)
#row = curs.next()
del curs, row Actually, you need to include both your reading and writing fields.
... View more
08-01-2012
09:21 AM
|
0
|
0
|
1949
|
|
POST
|
As seen here. http://stackoverflow.com/questions/678236/how-to-get-the-filename-without-the-extension-from-a-path-in-python os.path.splitext(os.path.basename(fc))[0]
... View more
08-01-2012
05:48 AM
|
0
|
0
|
1354
|
|
POST
|
It depends how you listed your files and passed your variable to the describe tool. If you used anything but arcpy.ListRasters() or arcpy.ListDatasets it won't work as Esri Grids are stored as folders not files. I'm not sure why it would work as stand alone and not in a script tool.
... View more
07-31-2012
02:44 PM
|
0
|
0
|
1032
|
|
POST
|
Remove the second string index reference to the name_field variable in your output line. Should look like this. txt.write("<</T({0})/V({1})>>\n".format(name_field,item))
... View more
07-31-2012
02:16 PM
|
0
|
0
|
731
|
|
POST
|
I'm not sure if you want the FDF_Field_Name variable inserted where you had it as a string before, but I did and you can change it back if that isn't what you are looking for. FDF_Field_Name = "Member" for index,item in enumerate(lMembers,1): name_field = "{0}{1}".format(FDF_Field_Name,index) txt.write("<</T({0})/V({0}{1})>>\n".format(name_field,item)) arcpy.AddMessage(item) Say this is your list. lMembers = ["Joe","Sue","Anne"] This will return for the first loop name_field = "Member1" item = "Joe" With that you can do what you want in terms of formatting for writing to your output.
... View more
07-31-2012
01:36 PM
|
0
|
0
|
4825
|
|
POST
|
Sorry for being unclear. As I mentioned, ultimately I'm writing values to an FDF file, which will be used in conjunction with a PDF template. The PDF contains fields for each Member, there can be up to 9 members. The fields are named Member1, Member2, etc. through Member9. The line of code that writes the values out is this. Using the field name in the PDF/FDF, and the data from the script
txt.write("<</T(FDF Field Name)/V(" + str(arcpy variable name) + ")>>\n")
[\code]
I have potentially 9 team members, but not always. I may have none or some, not always 9.
I'm trying to write these values in a loop. So something like this
Loop through the members list
create a variable for each item in the list
populate that variable with the value from the list
write that variableto the FDF file using txt.write
so the loop would actually contain the txt.write
for item in lMembers:
FDF_Field_Name = FDF_Field_Name+item
FDF_Field_Name+item = lmembers+string_value
txt.write("<</T(FDF_Field_Name)/V(" + str(FDF_Field_Name+item) + ")>>\n")
arcpy.AddMessage(item)
something like that, probably clear as mud now ;) Cheers So would this be an example of the strings you want to pass? FDF_Field_Name = "Member1"
item = "Joe"
... View more
07-31-2012
12:09 PM
|
0
|
0
|
2566
|
|
POST
|
What I think you are asking is if you can use selections made interactively in arcmap and pass those to the tool. The answer should be yes as long as you reference the layer with the selection in your tool. I haven't jumped in to addins for 10.1 myself yet but you can achieve this functionality with a regular script tool so I assume the same would hold for the new version.
... View more
07-31-2012
11:30 AM
|
0
|
0
|
961
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-17-2011 10:36 AM | |
| 1 | 08-16-2012 10:48 AM | |
| 1 | 10-31-2012 08:39 AM | |
| 1 | 07-16-2012 01:52 PM | |
| 1 | 03-15-2012 10:57 AM |
| Online Status |
Offline
|
| Date Last Visited |
08-22-2024
11:12 PM
|