|
POST
|
Hello, The .classValues property is read/write but I'm curious about the following line: Then assign the value list �??lyr.symbology.classValues�?? to customized �??Values�?? The values in the values list MUST match the data in the field being used to generate the unique values. You can't change the values to anything you want (but you can change the labels as long as both lists have the same length). For example, lets say these are all the values: ["a","b","c","d","e"]. I can NOT do this:
cList = ["f", "g", "h", "i", "j"] ## these values don't exist in my data.
sym.classValues = aList
Nothing will happen as you describe in your scenario. The point of writing the value list is that you may want to generate a subset of values.
cList = ["a", "b", "c"]
lList = ["apples", "bananas", "cherries"]
sym.classValues = aList
sym.classLables = lList
After a refresh you would only see 3 unique values instead of 5. Jeff
... View more
08-12-2013
06:34 AM
|
0
|
0
|
6705
|
|
POST
|
What do you get when you run:
import arcpy
mapdoc = arcpy.mapping.MapDocument(r"C:\data\Population.mxd")
df = arcpy.mapping.ListDataFrames(mapdoc, "layers")[0]
lyr = arcpy.mapping.ListLayers(mapdoc, "Population", df)[0]
lyrFile = arcpy.mapping.Layer(r"C:\data\update_layer.lyr")
arcpy.mapping.UpdateLayer(df, lyr, lyrFile, True)
print lyr.symbologyType
What does the print statement give you?
... View more
08-08-2013
06:03 AM
|
0
|
0
|
3308
|
|
POST
|
Hello, Curious, why are you using UpdateLayer when you can directly change the classbreak values and descriptions directly. Is it because the initial layer does not use the graduated symbols symbology? Make sure the update layer also uses the right renderer. Could it be possible that you are updating a layer with symbology from a layerfile that has classbreak information that doesn't match you underlying source data? Before changing the classbreak values and descriptions, did you try:
lyr.symbology.reclassify()
Jeff
... View more
08-07-2013
06:00 AM
|
0
|
0
|
3308
|
|
POST
|
Not sure, never got an update after the last suggestion. Can you export from the UI via File Export (to PDF)? If it works from the UI and your code is as simple as the example post above, and it still doesn't work, I would suggest contacting Tech Support. Jeff
... View more
07-26-2013
06:28 AM
|
0
|
0
|
4571
|
|
POST
|
I could reproduce your naming one / name all problem. I fixed it by placing the reference to the layer file within my loop and deleting the variable before the next iteration. import arcpy, os mxd = arcpy.mapping.MapDocument(r"C:\Temp\Test.mxd") df = arcpy.mapping.ListDataFrames(mxd)[0] for lyr in arcpy.mapping.ListLayers(mxd): lyrFile = arcpy.mapping.Layer(r"C:\Temp\Test.lyr") layerName = lyr.name arcpy.mapping.UpdateLayer(df, lyr, lyrFile, False) lyr.name = layerName del lyrFile mxd.saveACopy(r"C:\Temp\Test2.mxd") del mxd os.startfile(r"C:\Temp\Test2.mxd") I'd really like to understand the utility of updating 100+ layers so they are all identical except for their name. When we designed UpdateLayer we were thinking of scenarios where a single layer either in one MXD or across many MXDs would be updated. I'd like to learn more about your scenario. Thanks, Jeff
... View more
07-23-2013
06:37 AM
|
0
|
0
|
1518
|
|
POST
|
It can't be done with the arcpy.mapping module. I don't know if it can be done with arcpy. Jeff
... View more
07-22-2013
06:05 AM
|
0
|
0
|
2578
|
|
POST
|
It is not possible to move elements from one mxd to another. You may also want to look into cloning. Graphic and Text elements can be cloned. You could author the lines and text and then clone elements as you need them to dynamically build your title blocks using scripting logic. The following sample shows how to use arcpy.mapping cloning to build dynamic tables. http://www.arcgis.com/home/item.html?id=3a525b986b774a3f9cbbd8daf2435852 Jeff
... View more
07-15-2013
06:19 AM
|
0
|
0
|
1127
|
|
POST
|
You are not saving the changes to the mxd. Try: mxd.save() or mxd.saveACopy(new path) These lines would need to be at the same indent space as the mxd variable. Jeff
... View more
06-06-2013
06:45 AM
|
0
|
0
|
2332
|
|
POST
|
You could have something like:
import arcpy
fileExt = arcpy.GetParameterAsText(0) #Examples are [".JPG", ".PDF", ".TIF"]
newPDF=exportPath+"\\"+newName+fileExt
if fileExt == ".PDF":
exportToPDF
elif fileExt == ".TIF":
exportToTIF
etc
Jeff
... View more
05-24-2013
07:32 AM
|
0
|
0
|
1340
|
|
POST
|
I just verified this and it is working at 10.1. If df.rotation=0 my x and y min/max values appear in the expected LL and UR corners. If I set df.rotation = 45. It reports back to me the correct min/max values but they do not appear in the same locations. Because the df was rotated, my MinY appears in the LR corner and my MaxY appears in the UL corner. Is this what you were seeing but expected to get LL and UR coordinates? When you rotate a df you can't expect X values to remain constant along the top and bottom of the frame. If you want the coordinates in the corners of the df, then one possible solution would be to convert the extent rectangle into 4 points and then read the coordinates. Jeff
... View more
05-24-2013
06:52 AM
|
0
|
0
|
1269
|
|
POST
|
Define a parameter as a value list. http://resources.arcgis.com/en/help/main/10.1/index.html#//001500000028000000 Once you do that, you will need extra logic in your code to call the correct arcpy.mapping export funtion. Jeff
... View more
05-23-2013
06:46 AM
|
0
|
0
|
1340
|
|
POST
|
If this is truely a problem, please report this to support services. They'll need data and repro steps. Thanks, Jeff
... View more
05-23-2013
06:40 AM
|
0
|
0
|
2382
|
|
POST
|
James, you are correct. Graphic or text elements can only be cloned within a single map document. Jeff
... View more
05-16-2013
06:08 AM
|
0
|
0
|
4229
|
|
POST
|
All "CURRENT" means is that your code is referencing the document that is currently loaded into the ArcMap application. This means the code is being run from either the Python window or from a script tool from within ArcMap. The document that is open should have all your extra stuff, often times tucked away off the page. Your code can call it when/if needed. Jeff
... View more
05-15-2013
06:08 AM
|
0
|
0
|
3277
|
|
POST
|
I'm sorry Brian. I tried to clean up the variable names so they would be more meaningful. I should stop doing that after I have the code working. Here is the corrected code. ListLayers does work on layer files. Think of a layerfile as being a container of layers, just like an MXD. In many cases a layer file may only be a single layer but when you have group layers, it can be many layers.
import arcpy
fullLyr = arcpy.mapping.Layer(r"C:\Temp\FullPath.lyr")
lyrs = arcpy.mapping.ListLayers(fullLyr)
for lyr in lyrs:
if lyr.supports("DATASOURCE"):
lyr.findAndReplaceWorkspacePath(r"C:\Temp", r"C:\Active\ArcPY\ScrumWorks\Data")
fullLyr.saveACopy(r"C:\Temp\FullPath2.lyr")
rellLyr = arcpy.mapping.Layer(r"C:\Temp\RelPath.lyr")
lyrs = arcpy.mapping.ListLayers(rellLyr)
for lyr in lyrs:
if lyr.supports("DATASOURCE"):
lyr.findAndReplaceWorkspacePath(r"C:\Temp", r"C:\Active\ArcPY\ScrumWorks\Data")
relLyr.saveACopy(r"C:\Temp\RelPath2.lyr")
I hope this helps you, Jeff
... View more
05-14-2013
06:39 AM
|
0
|
0
|
912
|
| 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
|