Hi every guys,I want to modify a mxd file’s ”Lyr.symbology.classLabels”(see in Figure1),The main steps as follows:
First,According to Layer‘s name and Checks whether the property of the Layer is UniqueValuesSymbology, Then assign the value list ‘lyr.symbology.classValues’ to customized ‘Values’ List;
What's wrong? I wonder if the property ‘symbology.classLabels’can not modified ,but I read ESRI’s online help document (UniqueValuesSymbology (arcpy.mapping))and know it can read and write ,and there is an Example in the topic.
Has anyone modified UniqueValuesSymbology’s property ‘symbology.classLabels’ successfull? Any help will be appreciated ! Thank you very much!
First,According to Layer‘s name and Checks whether the property of the Layer is UniqueValuesSymbology, Then assign the value list ‘lyr.symbology.classValues’ to customized ‘Values’ List;
Figure 1 Layer’s UniqueValuesSymbology
Attachment 26627
Figure 2 value_label dictionary
Attachment 26628
Figure 3 Expect layers appear’s UniqueValuesSymbology
Attachment 26629
Code:
'''
#According mxd's LayerName to modify symbology.classLabels
'''
def EditLyrSymInfo(mxd,lyrName):
lyr = arcpy.mapping.ListLayers(mxd, lyrName)[0]
if lyr.symbologyType == "UNIQUE_VALUES":
Labels=lyr.symbology.classLabels
Values=lyr.symbology.classValues
#use this upt_Labels List to update Layer's symbology.classLabels
upt_Labels=[]
for value in Values:
#value_label dictionary's value in Figure 2
upt_label=label_value[value]
upt_Labels.append(upt_label)
print u'Labels:{0}, Values:{1};'.format(upt_label,value)
lyr.symbology.classLabels=upt_Labels
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
Has anyone modified UniqueValuesSymbology’s property ‘symbology.classLabels’ successfull? Any help will be appreciated ! Thank you very much!