Running ArcMap 10.1
So, I have a bunch of layers that all have the same name. I'm trying to rename them so that they have names that actually mean something.
Everything runs fine until it is time for the names to actually change. Nothing happens, and I don't know why.
Here is my code:
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Users\User\Documents\GISProj\Map6.mxd")
names=['Alexander','Avery','Buncombe','Burke','Caldwell','Cleveland','Durham','Gaston','Henderson','Jackson','Macon','Orange','Polk','Rutherford','Stokes','Surry','Transylvania','Watauga','Wilkes']
names.reverse()
cntys=arcpy.mapping.ListLayers(mxd,'slope')
for c in cntys:
c.name=names[cntys.index(c)]
arcpy.RefreshTOC()
after I run it, I can see that cntys returns
[<map layer u'Wilkes'>, <map layer u'Watauga'>, <map layer u'Transylvania'>, <map layer u'Surry'>, <map layer u'Stokes'>, <map layer u'Rutherford'>, <map layer u'Polk'>, <map layer u'Orange'>, <map layer u'Macon'>, <map layer u'Jackson'>, <map layer u'Henderson'>, <map layer u'Gaston'>, <map layer u'Durham'>, <map layer u'Cleveland'>, <map layer u'Caldwell'>, <map layer u'Burke'>, <map layer u'Buncombe'>, <map layer u'Avery'>, <map layer u'Alexander'>]
just like it should. But the actual layer names in the TOC don't change, even when I save, close, and reopen the map.
From what I'm looking at here:https://geonet.esri.com/thread/43148 and here:Use ArcPy to rename MXD layers it should work, but it doesn't. Whats up with this?