import arcpy, os from arcpy import env env.workspace = os.getcwd() mxd = arcpy.mapping.MapDocument(env.workspace + r"\CoastalCurrentsData.mxd") # Dataframe stuff - perform an arcpy.mapping UpdateLayer (using the above pre-authors layer file) df = arcpy.mapping.ListDataFrames(mxd, "CoastalCurrentsData")[0] updateLayer = arcpy.mapping.ListLayers(mxd, "RecentData", df)[0] sourceLayer = arcpy.mapping.Layer(env.workspace + r"\USWC_1km_WGS_1984.lyr") arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, True) # Refresh the layers unique value symbology so that it is referencing the current data lyr = arcpy.mapping.ListLayers(mxd, "RecentData", df)[0] # HERE'S WHERE THE ERROR HAPPENS ####### lyr.symbology.addAllValues() arcpy.RefreshActiveView() arcpy.RefreshTOC()
import arcpy, os from arcpy import env env.workspace = os.getcwd() mxd = arcpy.mapping.MapDocument(env.workspace + r"\CoastalCurrentsData.mxd") df = arcpy.mapping.ListDataFrames(mxd)[0] lyr = arcpy.mapping.Layer("RecentData") lyr.symbology.addAllValues() arcpy.RefreshActiveView() arcpy.RefreshTOC()
import arcpy, os from arcpy import env env.workspace = os.getcwd() mxd = arcpy.mapping.MapDocument(env.workspace + r"\CoastalCurrentsData.mxd") # Dataframe stuff - perform an arcpy.mapping UpdateLayer (using the above pre-authors layer file) df = arcpy.mapping.ListDataFrames(mxd, "CoastalCurrentsData")[0] updateLayer = arcpy.mapping.ListLayers(mxd, "RecentData", df)[0] sourceLayer = arcpy.mapping.Layer(env.workspace + "/USWC_1km_WGS_1984.lyr") arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, True) # Refresh the layers unique value symbology so that it is referencing the current data # HERE'S WHERE THE ERROR HAPPENS ####### sourceLayer.symbology.addAllValues() # AttributeError: 'Layer' object has no attribute 'symbology' arcpy.RefreshActiveView() arcpy.RefreshTOC()
import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "DataFrame")[0] # Refresh the layers unique value symbology so that it is referencing the current data lyr = arcpy.mapping.ListLayers(mxd, "TestingLayer", df)[0] lyr.symbology.addAllValues() arcpy.RefreshActiveView() arcpy.RefreshTOC()
import arcpy, os from arcpy import env env.workspace = os.getcwd() mxd = arcpy.mapping.MapDocument(env.workspace + r"\CoastalCurrentsData.mxd") df = arcpy.mapping.ListDataFrames(mxd, "CoastalCurrentsData")[0] # Refresh the layers unique value symbology so that it is referencing the current data lyr = arcpy.mapping.ListLayers(mxd, "RecentData", df)[0] lyr.symbology.addAllValues() # AttributeError: 'Layer' object has no attribute 'symbology' arcpy.RefreshActiveView() arcpy.RefreshTOC()
Hi Matthew,
Did you ever figure out why you were getting the error: 'Layer' object has no attribute 'symbology'
I'm running into the same problem.
Thanks for any help,
Brian
import arcpy mxd = arcpy.mapping.MapDocument("current") lyr = arcpy.mapping.ListLayers(mxd, "Population")[0] if lyr.symbologyType == "UNIQUE_VALUES": lyr.symbology.valueField = "SUB_REGION" lyr.symbology.addAllValues() arcpy.RefreshActiveView() arcpy.RefreshTOC() del mxd