|
POST
|
dkwiens you were right my data frame was "Layers". mzcoyle thank you very much for that code. I changed the df_name = "Main Map" to df_name = "Layers" and it zoomed to it. My next questions how do you get to highlight they feature you searched for. Highlighting is cleared at the end, remove this line to retain highlighting. arcpy.SelectLayerByAttribute_management(lyr,"CLEAR_SELECTION")
... View more
05-09-2012
01:48 PM
|
0
|
0
|
1471
|
|
POST
|
Hey Tony, sorry forgot about getting back to you. You can do something like this. import arcpy arcpy.AddMessage("Starting") acc_val = arcpy.GetParameterAsText(0) arcpy.AddMessage(acc_val) df_name = "Main Map" lyr_name = "TAXPARCELS" field_name = "ACCTEXT" mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, df_name)[0] lyr = arcpy.mapping.ListLayers(mxd, lyr_name, df)[0] arcpy.AddMessage(lyr.name) datasource = lyr.workspacePath field_delim = arcpy.AddFieldDelimiters(datasource,field_name) expression = "{0} = '{1}'".format(field_name,acc_val) arcpy.AddMessage(expression) arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",expression) df.extent = lyr.getSelectedExtent() df.scale = df.scale*1.1 for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "P"): if elm.name == "P": elm.text = (acc_val) arcpy.SelectLayerByAttribute_management(lyr,"CLEAR_SELECTION") arcpy.RefreshActiveView() arcpy.AddMessage("Completed")
... View more
05-09-2012
01:25 PM
|
0
|
0
|
1471
|
|
POST
|
This works fine for me. installdir = arcpy.GetInstallInfo("desktop")
outCS = arcpy.SpatialReference(installdir["InstallDir"]+r"Coordinate Systems\Projected Coordinate Systems\UTM\WGS 1984\Northern Hemisphere\WGS 1984 UTM Zone 32N.prj")
... View more
05-09-2012
10:53 AM
|
0
|
0
|
1678
|
|
POST
|
I think this is one place, amongst many, where ESRI can improve the error messages in python. The error message "Runtime error <type 'exceptions.RuntimeError'>: ERROR 999999: Error executing function" is so generic that it is hard to pinpoint what the exact problem is with the code. It would have been nice if the error message could inform the developer that it was looking for a prj file and not a text string that was representing the name of the projection. I agree, error catching could be improved greatly. In this case though, it seems to me more a problem with how spatial reference objects are passed in tools as strings. By having strings as object inputs, it is very difficult for error catching to determine what is wrong with your string, just it wasn't the string it was expecting. For error catching, I would find it great if they would at least give you an index number of the input that crapped out the tool, as opposed to failing the tool entirely.
... View more
05-09-2012
08:38 AM
|
0
|
0
|
1678
|
|
POST
|
You need to reference a projection file, not a projection name.
... View more
05-09-2012
07:58 AM
|
0
|
0
|
1704
|
|
POST
|
You try running the JoinField tool from the Python window in ArcGIS and you are getting a tool is not licensed error? You aren't trying to use any extensions? That is odd behaviour, are you on a floating or single use license? View, Editor, Info? JoinField says it is available at any license level, so not even sure why that would be an issue. Have you tried it on different data? Licensing issues are generally best handled by Esri support, I'm just grasping at straws.
... View more
05-09-2012
05:36 AM
|
0
|
0
|
744
|
|
POST
|
sys.argv[0] should be the name of the script. sys.argv[1] would be the first parameter. This is different than GetParameterAsText. Joan, Unless you're going to be working with Arc/INFO coverages, you probably don't want to use CreateArcInfoWorkspace. Use os.mkdir to create a directory for storing shapefiles, or CreateFileGDB for a file geodatabase. Ah that's right. The only time I've used sys.argv I was doing processing using the script name as an input, that's probably how I got turned around.
... View more
05-08-2012
10:49 AM
|
0
|
0
|
3297
|
|
POST
|
I'd suspect, based on your code, that you only have one argument passing to your script. In that case you would want sys.argv[0]. In Python, as in most computer languages, counting starts at 0.
... View more
05-08-2012
09:43 AM
|
0
|
0
|
3297
|
|
POST
|
As far as I know, ArcGIS uses more built in functions for their intellisense, not directly referencing the python libraries that are being called. arcpy.env.workspace for example. Not sure if they compiled the da module in the same manner that wouldn't be available to external editors.
... View more
05-07-2012
12:24 PM
|
0
|
0
|
4160
|
|
POST
|
In pyscripter, go to Tools > Python Path... do the folders show up as 10.0 or 10.1? For my system, the critical one is this "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy" If it is still referencing 10.0, just browse to the arcpy folder in your ArcGIS 10.1 install directory and add that path. You will then have to restart pyscripter.
... View more
05-07-2012
10:12 AM
|
0
|
0
|
4160
|
|
POST
|
Not sure what arcpy.da is. What extension does it require? Edit: Nevermind, Data Access Module, new with 10.1. Is it available in the python window in ArcGIS? Did you upgrade this machine from 10 to 10.1? Did you uninstall the previous version of Python prior to installed the new Python?
... View more
05-07-2012
07:23 AM
|
0
|
0
|
4160
|
|
POST
|
pu is just the variable name you are passing, short for planning unit in this case. The parameter is just a string that is searched for in the field "PLANNINGUNIT", in layer "PLANNING UNIT" in data frame "Main Map" in the current mxd. It also changes the layout text object named "PU" to the searched string.
... View more
05-07-2012
05:09 AM
|
0
|
0
|
1905
|
|
POST
|
Try this. dateTimeExp = "str(!AccDate!) + ' ' + str(!AccTime!)"
... View more
05-03-2012
01:54 PM
|
0
|
0
|
1001
|
|
POST
|
Oh you mean the shape area of the feature? If you want that as you are working in ArcMap, that would have to be ArcObjects. You could write a script that does that if you just want it for exporting. I've never tried it with data driven pages before, here's a bit of code to get you on the path. for page in export_loop:
layer = "data_driven_layer"
ddp_field = "Field_Name"
desc = arcpy.Describe(layer)
shapeField = desc.shapeFieldName
where = "%s = '%s'" %(ddp_field,ddp_value)
s_cursor = arcpy.SearchCursor(layer,where)
for row in rows:
page_area = row.getValue(shapeField).area
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if elm.name == "Dyn_Area":
elm.text = page_area Edit: What Darren said below. My suggestion would be more use accessing other layers attributes based on the current data driven page.
... View more
05-03-2012
11:07 AM
|
0
|
0
|
1162
|
| 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
|