|
POST
|
It looks very similar to the sample provided in help. Have you set your workspace environment? Have you tried arcpy.mapping UpdateLayer? http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/UpdateLayer/00s30000003p000000/ Jeff
... View more
05-14-2012
07:18 AM
|
0
|
0
|
532
|
|
POST
|
Thanks - my bad! - that is what I get for typing code from memory. Here is more complete code:
mxd = arcpy.mapping.MapDocument("current")
lyr = arcpy.mapping.ListLayers(mxd, "my layer")[0]
desc = arcpy.Describe(lyr.dataSource)
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
dfExtent = df.extent
dfExtent.XMin = desc.extent.XMin
dfExtent.XMax = desc.extent.XMax
dfExtent.YMin = desc.extent.YMin
dfExtent.YMax = desc.extent.YMax
df.extent = dfExtent
Note - this code does work, I ran it. 🙂 Jeff
... View more
05-14-2012
06:53 AM
|
0
|
0
|
1959
|
|
POST
|
Very bizzare. We had a somewhat related issue a while back with extents getting reset when you enable/disabled DDP. But that was addressed in SP3. What SP are you currently on? Would you be able to share a map package, send to [email protected]. Jeff
... View more
05-14-2012
06:20 AM
|
0
|
0
|
2134
|
|
POST
|
You can do this two ways.
mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "myLayer")[0]
#Zoom to all selected features in data frame
df.zoomToSelectedFeatures()
#Zoom to selected features for a specific layer.
df.extent = lyr.getSelectedExtent()
arcpy.RefreshActiveView()
Jeff
... View more
05-09-2012
08:55 AM
|
0
|
0
|
2694
|
|
POST
|
This should have been addressed at 10.0 SP3 with NIM067149: Block Web service layers from supporting layer.dataSource. The example in the previous post solves one problem but will introduce another if something. The correct solution should be: I just confirmed this on a 10.0 SP3 machine. Image Server layers no longer show up as layers that support the lyr.support("DATASOURCE") property. Before attempting to change a data source, check to see if this property is true.
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("DATASOURCE"): If you are still having a problem, please send me a map package so I can test with your data.
Thanks, Jeff
... View more
05-08-2012
07:49 AM
|
0
|
0
|
1660
|
|
POST
|
The following script will export all MXDs in a folder to JPG: import arcpy, os inputPath = some path outputPath = some other path #Loop through each MXD file for filename in os.listdir(inputPath): fullpath = os.path.join(inputPath, filename) if os.path.isfile(fullpath): if filename.lower().endswith(".mxd"): #Reference MXD and export mxd = arcpy.mapping.MapDocument(fullpath) arcpy.mapping.ExportToJPEG(mxd, outputPath + "\\" + filename + ".jpg") Jeff
... View more
05-07-2012
08:24 AM
|
0
|
0
|
1251
|
|
POST
|
Unfortunately, we did not expose Unique Values, many fields at 10.1. We did expose Unique Values and it is possible to add multiple lines to each description. The example below modifies the descriptions of 2 unique values.
mxd = arcpy.mapping.MapDocument("current")
lyr = arcpy.mapping.ListLayers(mxd, "my Unique Value Layer")[0]
if lyr.symbologyType == "UNIQUE_VALUES":
lyrSym = lyr.symbology
lyrSym.classDescriptions = ["temp1\r\ntemp2", "temp1\r\ntemp2"]
Jeff
... View more
05-07-2012
08:11 AM
|
0
|
0
|
1311
|
|
POST
|
That is great that you figured this out. Using tags is really the only way to modify individual text properties on a layout. At 10.1 we did add fontSize but that is it. Jeff
... View more
05-07-2012
08:03 AM
|
0
|
0
|
1164
|
|
POST
|
Have you considered using arcpy.mapping? It is a great substitute for many common tasks and can accomplish what you are trying to do. You can change query definitions on a layer using the layer object: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/ For good resources on how to get started, check out: http://blogs.esri.com/esri/arcgis/2011/09/30/new-resources-available-for-getting-started-with-python-map-automation/ Jeff
... View more
05-07-2012
07:40 AM
|
0
|
0
|
2694
|
|
POST
|
Have you considered arcpy.mapping? Check out: arcpy.mapping.PrintMap: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/PrintMap/00s300000037000000/ arcpy.mapping.ListPrinterNames: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/ListPrinterNames/00s30000000w000000/ arcpy.mapping.ExportToPDF: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/ExportToPDF/00s300000027000000/ Jeff
... View more
05-03-2012
08:16 AM
|
0
|
0
|
682
|
|
POST
|
What type of symbology are you using on your layer? At 10.1 we've added some new symbology options but it depends on the symbology type (e.g., graduated colors, graduated symbols, etc). Also - where in the UI are you changing the layer item descriptions so that it has more than more line per symbol. I'm not able to do it in the UI. I'm trying to do it via layer properties --> symbology tab. For unique value, I select the individual symbol, right-click and select Edit Description. It does NOT allow multiple lines. Jeff
... View more
05-03-2012
07:19 AM
|
0
|
0
|
1311
|
|
POST
|
AddAllValues is reapplying the symbology back to the existing values in a random fashion the same way that the user interface works. For example, add a feature class to the user interface and open the layer properties dialog. Via the symbology tab set the symbology to Unique Value and click the "Add All Values" button mutliple times. Each time you click, the symbols for the existing features change. I think what you want to do is use arcpy.mapping.Updatelayer. This will update your shapefile using the symbology from the layer file and it will preserve the symbology for the matching symbols. One problem is that UpdateLayer will bring across all unique values into the TOC and if you insert a legend, lables will appear. At 10.1, the way to get around this is to check off "Only show classes that are in the visible extent".
mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(mxd, "layers")[0]
myShape = arcpy.mapping.ListLayers(mxd, "MyShape")[0]
lyrFile = arcpy.mapping.Layer(r"C:\Path\To\layerfile.lyr")
arcpy.UpdateLayer(df, myShape, lyrFile, True)
I hope this helps, Jeff
... View more
05-02-2012
07:06 AM
|
0
|
0
|
1151
|
|
POST
|
This code looks really familiar, did you get it from the Dynamic Graphic Table sample? At a quick glance, the code looks fine. Are you sure your query is working and that rows are being returned? You should try adding a "print count" statement to see if count is > 0. Jeff
... View more
05-01-2012
07:01 AM
|
0
|
0
|
775
|
|
POST
|
Have you tried mxd.replaceWorkspaces? MXD.findAndReplaceWorkspacePaths doesn't work as well for changing owner information. Jeff
... View more
04-30-2012
09:18 AM
|
0
|
0
|
687
|
|
POST
|
Is there a problem with .addAllValues() or are you looking for a way to add only some values. Because .addAllValues adds ALL values. You may want to try working with layer files that contain the unique set of values you are interested in. You could add the layer and it would be possible to change the data source on the layer. Jeff
... View more
04-30-2012
09:15 AM
|
0
|
0
|
1151
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-05-2025 11:20 AM | |
| 3 | 06-05-2025 09:21 AM | |
| 1 | 05-14-2025 01:19 PM | |
| 2 | 04-24-2025 07:54 AM | |
| 1 | 03-15-2025 07:19 PM |
| Online Status |
Offline
|
| Date Last Visited |
06-23-2026
10:29 AM
|