In an active ArcMap session - I want to change the symbology of a layer which is repeated multiple times in the mxd. Can I do this?
The basic code I have for getting the layers is below. This is running within ArcMap (not as a .py script)
myMXD = arcpy.mapping.MapDocument("Current")
lstDataFrames=arcpy.mapping.ListDataFrames(myMXD)
lstLayers=arcpy.mapping.ListLayers(myMXD)
hazardLayer=arcpy.mapping.ListLayers(myMXD,'*Haz*')
allFrames=arcpy.mapping.ListDataFrames(myMXD)
for dataFrame in allFrames:
myMXD.activeView=dataFrame
for mapLayer in hazardLayer:
mapLayer.visible=False
This just changes the visibility to off...can I change the color for example to some RGB value?
Answer
First create a default layer file to use as a template then:
myMXD = arcpy.mapping.MapDocument("Current")
lstDataFrames=arcpy.mapping.ListDataFrames(myMXD)
lstLayers=arcpy.mapping.ListLayers(myMXD)
hazardLayer=arcpy.mapping.ListLayers(myMXD,'*Haz*')
allFrames=arcpy.mapping.ListDataFrames(myMXD)
for dataFrame in allFrames:
myMXD.activeView=dataFrame
for mapLayer in hazardLayer:
arcpy.ApplySymbologyFromLayer_management(mapLayer, r"C:\TemplateLayers\HazardTemplate.lyr")
No comments:
Post a Comment