|
POST
|
The first argument to exportreport must be an arcpy.mapping object. For example: mxd = arcpy.mapping.MapDocument('current')
df = arcpy.mapping.ListDataFrames(mxd, 'Layers')[0]
layer = arcpy.mapping.ListLayers(df, '2013pp')[0]
arcpy.mapping.ExportReport(layer,"C:\reports\2013_Graffiti.rlf","C:\reports\2013_Graffiti_report.pdf")
... View more
06-20-2013
08:34 AM
|
0
|
0
|
2271
|
|
POST
|
Convert your .style files to .serverstyle using MakeServerStyleSet.exe, found in C:\Program Files (x86)\ArcGIS\Desktop10.1\bin\MakeServerStyleSet.exe
... View more
06-14-2013
11:50 AM
|
0
|
0
|
680
|
|
POST
|
Are you using server or 64 bit geoprocessing? .style files are only supported on Desktop, you may need to switch to .serverstyle files.
... View more
06-14-2013
08:28 AM
|
0
|
0
|
680
|
|
POST
|
Set up a new Derived Output parameter of type Feature Layer. Set its value to "LAYER" (or whatever you name it) in the execute method. This will notify the GP framework that this is indeed a layer you want to keep around and not a layer of intermediate data. You'll also get the benefit of not having to do any extra arcpy.mapping scripting. arcpy.MakeFeatureLayer_management(r"C:\BILL\CB_TEMP\cb.shp", "LAYER") arcpy.SetParameterAsText(1, "LAYER")
... View more
06-07-2013
12:45 PM
|
1
|
1
|
3066
|
|
POST
|
The list functions don't return lists if your geoprocessor is set above 9.3. To make it run in 9.3 mode, do this: gp = arcgisscripting.create(9.3) This will ensure the same behavior of this script even in 10.0/10.1. Then, use this idiom: for shape in iter(shapes.next, None): Since it returns a geoprocessing list object and not a Python list in 9.3.
... View more
05-30-2013
02:56 PM
|
0
|
0
|
4601
|
|
POST
|
Map and Layer refer to Map and Layer objects, not files. Since Walk does not go into MXD files at 10.1, these filters aren't particularly useful.
... View more
05-29-2013
12:12 PM
|
0
|
0
|
996
|
|
POST
|
If you have a pre-authored map, you could do something hacky like this: import os
import arcpy.mapping
# Crack open the map
mxd = arcpy.mapping.MapDocument(my_mxd)
data_frame = arcpy.mapping.ListDataFrames(mxd)[0]
# Iterate over the feature classes
for featureclass in feature_classes:
# Make a new geoprocessing layer
arcpy.management.MakeFeatureLayer(featureclass, 'temp_layer')
# Apply symbology to it
result = arcpy.management.ApplySymbologyFromLayer('temp_layer', r'c:\path\to\my\symbology\layer')
# getOutput(0) is an arcpy.mapping Layer object
layer_object = result.getOutput(0)
# Drop onto dataframe
arcpy.mapping.AddLayer(data_frame, layer_object)
# Set correct extent
data_frame.zoomToSelectedFeatures()
# Compute an output file name
out_file_name = r"c:\thumbnails\{basename}.png".format(basename=os.path.basename(featureclass))
# Export "thumbnail" of data frame
arcpy.mapping.ExportToPNG(mxd, out_file_name, data_frame, 128, 128)
# Pull the layer out of the data frame to make room for the next one
arcpy.mapping.RemoveLayer(data_frame, layer_object)
# Delete the GP layer
arcpy.management.Delete('temp_layer') Note you don't have to apply a symbology, you can just do # Make a new geoprocessing layer
result = arcpy.management.MakeFeatureLayer(featureclass, 'temp_layer')
# getOutput(0) is an arcpy.mapping Layer object
layer_object = result.getOutput(0) if you don't mind it being auto-symbolized like it does in GP tools.
... View more
05-28-2013
04:24 PM
|
0
|
0
|
1846
|
|
POST
|
You put that part with the import and def in the code block and change the expression to remove_codes(!TEXTSTRING!)
... View more
05-27-2013
03:48 AM
|
0
|
0
|
1737
|
|
POST
|
You can use regular expressions to take out the control codes in one fell swoop. import re
def remove_codes(code_string):
# Get rid of enclosed text, ie {\instruction;Text to keep}
replaced_sequences = re.sub(r"{\\[^;]+;([^}]*)}", r"\1", code_string)
# Get rid of standalone \font|22pt; like sequences
new_string = re.sub(r"\\[^;]+;", "", replaced_sequences)
return new_string And this gives us >>> remove_codes(r"\pt16.25;{\fArial|b0|i0|c0|p34;15.00m}")
'15.00m' in the Python window
... View more
05-26-2013
05:45 PM
|
0
|
0
|
1737
|
|
POST
|
Indentation error. Putting the try: statement at that indent level implicitly takes you out of the class definition and just defines an onClick function not bound to anything. Make it look like this:
import arcpy
import pythonaddins
import traceback
class ButtonClass11(object):
"""Implementation for test_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
try:
# Get the current map document and the first data frame.
mxd = arcpy.mapping.MapDocument('current')
df = arcpy.mapping.ListDataFrames(mxd)[0]
# Call the zoomToSelectedFeatures() method of the data frame class
df.zoomToSelectedFeatures()
except Exception as e:
traceback.print_exc()
... View more
05-22-2013
11:15 AM
|
0
|
0
|
648
|
|
POST
|
You may also want to be aware that internally Dates are stored as double precision floats, which are notoriously flaky once you get into large degrees of precision.
... View more
10-25-2012
08:27 AM
|
0
|
0
|
936
|
|
POST
|
Could you provide a (greatly) simplified version of your code here without all those extra library calls? You're using a lot of functions and have not provided any context, so I don't know if I can make any assessment of what's going on that can be accurate.
... View more
10-25-2012
08:25 AM
|
0
|
0
|
936
|
|
POST
|
This prebuilt version for 10.1 may be what you need.
... View more
10-14-2012
08:36 AM
|
0
|
0
|
4199
|
|
POST
|
You'd probably want to implement a tool with the onLine method defined, not a simple button. So something like this: class MyTool(object):
def __init__(self):
self.shape = 'Line'
def onLine(self, line_object):
line_length = line_object.length
# do something with line_length
... View more
10-10-2012
10:58 AM
|
0
|
0
|
425
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-26-2012 02:46 AM | |
| 2 | 01-06-2011 08:22 AM | |
| 1 | 03-25-2014 12:18 PM | |
| 1 | 08-12-2014 09:36 AM | |
| 1 | 03-31-2010 08:56 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:22 AM
|