Hi,
Can i add an item (layer "polygon") in the TOC to exist legend in arcmap using python?
I have a several mxd's with those layers:
I tried search in ArcGIS Help 10.1 but didn't find a way to do it.
Hi YYC,
Arcpy Mapping does not allow for individual layers to be manually added to a legend. However, you can set a legend to auto-add new layers added the map with add layer or addlayertoGroup to the legend. If you set this property to true before you add the layer you want, it should add it to your legend. If it already exists in the map, either moving it to a group layer or remove and adding it again should add it to the legend.
If you have a specific symbology defined for the polygon layer, you might want to save the layer as a layerfile (.lyr) before removing it (see saveACopy (file_name, {version}) method of Layer—Help | ArcGIS for Desktop )
In this help topic (10.3) LegendElement—Help | ArcGIS for Desktop sample code is provided that shows the use of the autoAdd property of the legend by python code.