|
POST
|
You could accomplish this with the evil uncle of arcpy, spoken here only in hushed whispers. ArcObjects
... View more
09-11-2012
08:14 AM
|
0
|
0
|
2778
|
|
POST
|
Is there a way of doing something similar and searching three fields with one input box? Possibly, you would need to describe your schema and values more though or post examples of your data.
... View more
09-11-2012
08:11 AM
|
0
|
0
|
1300
|
|
POST
|
Is it always the addfield function that breaks it or do other tools throw the same exception? In 10.0 I had a similar issue iirc with AddField. For some reason putting the parameters in a list and referencing those solved the issue. I may be misremembering though, it was several months ago now. I did read a post on here about 10.1 not releasing locks as fast as previously. Adding a Compact or Exists was the work around for it. Here's my code if you are interested. def addfields():
print "Adding fields"
field_name_list = [field.name for field in arcpy.ListFields(calc_table)]
add_fields = [
("TYPE", "TEXT", "#", "#", 40),
("ORIGIN_SITE", "TEXT", "#", "#", 10),
("UTYPE", "TEXT", "#", "#", 40),
("U_ORIGIN_SITE", "TEXT", "#", "#", 10),
("DEC_PER", "SHORT", "#", "#", "#"),
("LEAD_CON", "TEXT", "#", "#", 2),
("COV_GRP", "TEXT", "#", "#", 2),
("STRATA", "SHORT", "#", "#", "#"),
("CON_PIECE", "FLOAT", "#", "#", "#"),
("DEC_PIECE", "FLOAT", "#", "#", "#"),
("CON_VOLHA", "FLOAT", "#", "#", "#"),
("DEC_VOLHA", "FLOAT", "#", "#", "#"),
("UDEC_PER", "SHORT", "#", "#", "#"),
("UCOV_GRP", "TEXT", "#", "#", 2),
("ULEAD_CON", "TEXT", "#", "#", 2),
("TDASTRATUM", "TEXT", "#", "#", 8),
("UTDASTRATUM", "TEXT", "#", "#", 8)]
for field in add_fields:
if field[0] not in field_name_list:
arcpy.AddField_management(
calc_table,
field[0],
field[1],
field[2],
field[3],
field[4])
... View more
09-11-2012
07:54 AM
|
0
|
0
|
3034
|
|
POST
|
ArcServer editing requires at least a ArcServer Standard license I believe. http://www.esri.com/software/arcgis/arcgisserver/features/functionality-table If you have that, it looks like your SDE connection file is referenced to the local profile. I would imagine that isn't how you want to set it up on your server.
... View more
09-11-2012
07:40 AM
|
0
|
0
|
850
|
|
POST
|
Haven't seen it myself, came across this though. http://forums.esri.com/Thread.asp?c=93&f=1148&t=173933
... View more
09-10-2012
01:08 PM
|
0
|
0
|
1075
|
|
POST
|
Ok. I will see what I can do with that. Thanks for all your help! I made a slight addition to the loop to add the if/else to get the proper and statements added.
... View more
09-10-2012
01:01 PM
|
0
|
0
|
1300
|
|
POST
|
For each field you will need a new parameter added to your tool. There are a couple ways to go about it, and it gets a little more complicated if you want it to be dynamic (eg a user can select any number of fields to put in the query).
job_num = arcpy.GetParameterAsText(0)
job_num2 = arcpy.GetParameterAsText(1)
job_num3 = arcpy.GetParameterAsText(2)
...
# Create where clause for selection
query = ""
query_list = [("Job_Num", job_num), ("Job_Num2", job_num2), ("Job_Num3", job_num3)]
for field_name, variable in query_list:
if query == "":
query = "%s = '%s'" % (field_name, variable)
else:
query = query + " and %s = '%s'" % (field_name, variable)
Something like that should get you on track. May require some tinkering to make it work for you.
... View more
09-10-2012
12:45 PM
|
0
|
0
|
2289
|
|
POST
|
That was perfect!!! Your fast too! Just a couple questions? What was going on with the addmessages methods? Also some of these features have 1, 2, or 3 possible job numbers associated with them, as in fields Job_Num2, Job_Num3, so on.... Would there be a way add multiple fields to the query? Job_Num, or Job_Num2, or Job_Num3.. The addmessages are there just to check your variables to make sure they are what you are expecting. They are unnecessary for the script itself and more for trouble shooting. If you are selecting from multiple fields, are they all the same value from these fields? Or do you want unique values from each field? Eg Job_Num = "first" and Job_Num2 = "first"
# or
Job_Num = "first" and Job_Num2 = "second"
... View more
09-10-2012
12:04 PM
|
0
|
0
|
2289
|
|
POST
|
I am trying to create a simple tool to collect user input and zoom to selected feature. ideally would like to select from fc in toc. Any suggestions? Well first of all you don't have feature classes in your TOC, you have layers pointing to your feature classes on disk. These are the objects you make selections on, you cannot make selections on feature classes. Try running this as your script. You could also add another input parameter to select the layer manually. import arcpy
def main():
arcpy.AddMessage("Starting")
# Get and set variables
job_num = arcpy.GetParameterAsText(0)
layer_name = "tax_acct"
df_name = "Layers"
arcpy.AddMessage(job_num)
# Define mxd, df and lyr objects
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, df_name)[0]
lyr = arcpy.mapping.ListLayers(mxd, layer_name, df)[0]
arcpy.AddMessage(lyr.name)
# Create where clause for selection
query = "Job_Num = '%s'" % (job_num)
arcpy.AddMessage(query)
arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", query)
# Get number of selected features
selection = int(arcpy.GetCount_management(layer_name).getOutput(0))
arcpy.AddMessage("%s features selected" % (selection))
# Set df extent to layer selection
df.extent = lyr.getSelectedExtent()
arcpy.RefreshActiveView()
arcpy.AddMessage("Completed")
main()
... View more
09-10-2012
11:40 AM
|
0
|
0
|
2289
|
|
POST
|
[ATTACH=CONFIG]17579[/ATTACH] I can see 1 selected in results window but still no effect on dataframe? See attached... That is because you create a temporary layer called "layer" that you are basing your selections on. I don't see that layer in your TOC. Maybe you should describe what you want to accomplish since it looks like you are going about this the wrong way.
... View more
09-10-2012
11:22 AM
|
0
|
0
|
2289
|
|
POST
|
Try adding these lines at the end of your script. This will print how many features are selected, and then refresh the view to make those selections visible. selection = int(arcpy.GetCount_management("layer").getOutput(0))
arcpy.AddMessage("%s features selected" % (selection))
arcpy.RefreshActiveView()
... View more
09-10-2012
11:06 AM
|
0
|
0
|
2486
|
|
POST
|
This should work. You may need to add quotes around your field name, or use the add field delimiters tool to create them for dynamic data sources. # Model selects parcel from user input
import arcpy
# Assign variable to the feature class
featureClass = "G:\\PRAD\\PRAD_v10.1.gdb\\tax_acct"
# Assign variable to users input
input = arcpy.GetParameterAsText(0)
# Make a feature layer from feature class
arcpy.MakeFeatureLayer_management(featureClass, "layer")
# Build selection query
query = "Job_Num = '%s'" % (input) # May need change to "\"Job_Num\" = '%s'"
# Apply a selection to the feature layer
arcpy.SelectLayerByAttribute_management("layer", "NEW_SELECTION", query)
... View more
09-10-2012
10:46 AM
|
0
|
0
|
2486
|
|
POST
|
Depending on your data type it could look something like this. input = "\"CITY_NAME\" = 'Chicago'" You can see more examples here. http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000071000000
... View more
09-10-2012
09:11 AM
|
0
|
0
|
2486
|
|
POST
|
You need to print out the actual value of the variable the tool is reading to make sure it is a valid query.
... View more
09-10-2012
09:03 AM
|
0
|
0
|
2486
|
| 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
|