|
POST
|
If you just need to enter a value and zoom to that feature you can make a simple script tool, something along these lines. Add it to a toolbox and then make it a button. import arcpy
arcpy.AddMessage("Starting")
city = arcpy.GetParameterAsText(0)
arcpy.AddMessage(city)
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Cities, Towns and Urban Service Areas", df)[0]
arcpy.AddMessage(lyr.name)
expression = "NAME = '"+city+"'"
arcpy.AddMessage(expression)
arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",expression)
df.extent = lyr.getSelectedExtent()
df.scale = df.scale*1.2
arcpy.RefreshActiveView()
... View more
09-07-2011
01:44 PM
|
0
|
0
|
780
|
|
POST
|
If you are having memory issue you need to make your metafile as SMALL as possible, not bigger. It could also be an issue with your printer running out of memory, even with a print server we noticed this on our plotters. This is exacerbated when using high DPI outputs. Try running the script without the pdf export, or vice versa, and see if you still get the issue.
... View more
09-07-2011
01:39 PM
|
0
|
0
|
430
|
|
POST
|
Actually now that I think about it, you can have some other character that you can split on and input those as variables surrounded by the returns, something like this.
desc = arcpy.GetParameter(0)
desc = desc.split("#")
mxd.description = desc[0]+"\r\n"+desc[1]
... View more
08-30-2011
12:26 PM
|
0
|
0
|
1039
|
|
POST
|
Ahh, sorry for my misunderstanding. The only solution I can see is to have a parameter for each line you want to add, workable if you have a fixed number of lines to add each time.
... View more
08-30-2011
12:06 PM
|
0
|
0
|
1039
|
|
POST
|
Should work mxd.description= r'New Line 1\r\nNew Line 2'
... View more
08-30-2011
10:46 AM
|
0
|
0
|
1039
|
|
POST
|
Yo, you have two close brackets ), but only one open bracket (... This is invalid syntax, hence the syntax error. The number of brackets need to balance, I presume you actually wanted this: buffer = arcpy.Buffer_analysis(roads, "in_memory/buffer", "1000 Feet"), "", "", "ALL" ) And I presume you meant this? buffer = arcpy.Buffer_analysis(roads, "in_memory/buffer", "1000 Feet", "", "", "ALL" )
... View more
08-30-2011
05:06 AM
|
0
|
0
|
700
|
|
POST
|
If the feature is selected it should zoom to it no problem. Are you on SP2? Are you sure only 1 feature is being selected? Try manually selecting a feature and running this from the python window. If this doesn't work, something else is going on.
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "<Your Data Frame>")[0]
lyr = arcpy.mapping.ListLayers(mxd, "<Your Layer>", df)[0]
df.extent = lyr.getSelectedExtent()
... View more
08-29-2011
12:46 PM
|
0
|
0
|
2949
|
|
POST
|
I think you need to save your split as a new variable, or overwrite the existing one Edit: also the slash is a little out of whack when I tested it, try this "\\"
mxd = arcpy.mapping.MapDocument("CURRENT")
P = mxd.filePath
P = P.split("\\")[-1]
mxd.title = P
mxd.summary = "blah,blah, blah."
mxd.author = "James Kellough"
mxd.credits = "My Company"
mxd.description = "blah, blah, blah"
mxd.tags = "Script, Python, Arcpy"
del mxd
... View more
08-25-2011
01:22 PM
|
0
|
0
|
662
|
|
POST
|
Something simple like this should work.
import arcpy
arcpy.AddMessage("Starting")
val1 = arcpy.GetParameterAsText(0)
arcpy.AddMessage(val1)
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
lyr = arcpy.mapping.ListLayers(mxd, <Your Feature Layer>, df)[0]
arcpy.AddMessage(lyr.name)
expression = "<Your Fieldname> = '"+val1+"'"
arcpy.AddMessage(expression)
arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",expression)
df.extent = lyr.getSelectedExtent()
arcpy.RefreshActiveView()
... View more
08-24-2011
12:34 PM
|
0
|
0
|
2949
|
|
POST
|
Have you tried putting each line into the python window in ArcMap to see where an issue pops up? Where do you get errors? If this is supposed to be run on the mxd currently open you can change the mxd path to "CURRENT", also you shouldn't need to make the feature a feature layer if it is already in the mxd.
... View more
08-24-2011
12:06 PM
|
0
|
0
|
2949
|
|
POST
|
Shot in the dark, but did you try setting "False" to get the geometric extent instead of symbolized extent? d.extent = l.getExtent(False) I doubt that would be an issue, but like I said, shot in the dark. Another thing, will there always be a selection? There is another method to get an extent of selected features. d.extent = l.getSelectedExtent() You could also try getting just the layer you want instead of going through all of them recursively, l = arcpy.mapping.ListLayers(mxd, "Rail Roads", d)[0]
... View more
08-24-2011
06:11 AM
|
0
|
0
|
1093
|
|
POST
|
As soon as you import arcgisscripting it checks out a license. How many licenses do you have available? What may be happening is each script you are running that imports arcgisscripting is consuming a license and not releasing them when they are done.
... View more
08-18-2011
02:13 PM
|
0
|
0
|
1350
|
|
POST
|
The only reason I can see for that to happen is if it can't access the license manager, or doesn't think you have rights to access it. Are you using 9.3.1?
... View more
08-18-2011
01:53 PM
|
0
|
0
|
1350
|
|
POST
|
Editing an mxd outside of ArcMap, while that mxd is open in ArcMap, is not an easy feat to accomplish. The mxd will not recognize changes to scale, zooming, selections etc outside of the program accessing it, as all that is held in memory. You would have to make your edits using your GUI, save the mxd, then open ArcMap to see the changes. As far as I know, the only feasible way to accomplish what you want to do will require ArcObjects.
... View more
08-18-2011
01:45 PM
|
0
|
0
|
1084
|
| 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
|