Can the layer name in the TOC be updated using arcpy?

2879
2
08-19-2015 10:02 AM
RebeccaStrauch__GISP
MVP Emeritus

I'm working on a script to update all my broken links in my mxd's do to server and folder changes.  Some of these changes are from one data type to another. I'm working my way thru the various combinations, and now working on an old SDE to FGDB.  Unfortunately the name in my Table of Contents is still called the default SDE connection name (e.g. SDE_COMMON.SDEWILD.NED_HILLSHADECLIP).  I would like to rename this in the TOC to just NED_HILLSHAPECLIP in this case.

In short, I need to replace my   "lyr.name"  with   "lyr.datasetName"

Is there a way to do this in python?

I am trying to keep my script/tools 10.2.2 compatible.

Thanks.

0 Kudos
2 Replies
RebeccaStrauch__GISP
MVP Emeritus

ok...may have been overthinking this.  I think all I needed to do is

lyr.name = lyr.datasetName

when testing in the .mxd, I need to refresh the mxd/TOC.  This will be run in ArcCatalog and will test my script and update soon.

Sometimes writing out the question is enough to make the obvious pop out.  ugh!

IanMurray
Frequent Contributor

It happens to everyone.