curtvprice

Cannot update layer symbology

Discussion created by curtvprice Champion on Jun 20, 2014
Latest reply on Jun 20, 2014 by curtvprice
I am trying to follow the example in the help for Layer:

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Census")[0]
lyr = arcpy.mapping.ListLayers(mxd, "StatePopulation", df)[0]
lyrFile = arcpy.mapping.Layer(r"C:\Project\LYRs\Population.lyr")
arcpy.mapping.UpdateLayer(df, lyr, lyrFile, True)
if lyr.symbologyType == "GRADUATED_COLORS":
  lyr.symbology.valueField = "POP2000"
  lyr.symbology.numClasses = 4
  lyr.symbology.classBreakValues = [250000, 999999, 4999999, 9999999, 35000000]
  lyr.symbology.classBreakLabels = ["250,000 to 999,999", "1,000,000 to 4,999,999", 
                                    "5,000,000 to 9,999,999", "10,000,000 to 35,000,000"]


Here is my pathetic dialog with the Python window...

>>> mxd = am.MapDocument("current")
>>> df = am.ListDataFrames(mxd, "ValueMap")[0]
>>> df.name
u'ValueMap'
>>> lyr = am.ListLayers(mxd, "County*", df)[0]
>>> lyr.name
u'County Data'
>>> am.UpdateLayer(df, lyr, am.Layer("q.lyr"), True)
>>> lyr.symbology.valueField 
u'AQ_WGWTo.AQ_WGWTo_2010'
>>> lyr.symbologyType
u'GRADUATED_COLORS'
>>> lyr.symbology.numClasses = 5
Runtime error 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\arcgis\desktop10.2\arcpy\arcpy\arcobjects\_base.py", line 89, in _set
    return setattr(self._arc_object, attr_name, cval(val))
RuntimeError
>>> # however this works - and displays immediately in the map (with unchanged symbology)
>>> lyr.symbology.valueField = u'AQ_WGWTo.AQ_WGWTo_2000'
>>> # and this generates no error but does not change the break values as promised
>>> lyr.symbology.reclassify()


Any ideas what I'm doing wrong????

Outcomes