The lyr.name = "NewName" seems to work, but the layer is removed from the TOC. Basic Code below: # Import arcpy module import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] lyr = arcpy.mapping.ListLayers(mxd)[0] lyr.name = "NewName" arcpy.RefreshTOC() Has anyone else had this problem, and has come up with a solution? I will note that if you enter these lines directly into the command prompt they work fine, BUT if you inport the python script into a Toolbox there is a problem with the layer being removed. Any help would be appreciated.
... View more