Take the 2-minute tour ×  This is related to my question ArcPy
replaceDataSource, but can anyone explain to me why the
following code fails to add a valid layer from a .lyr file, and
I get the same problems as in that question (broken data
source):  import time import arcpy  fullpath = r'\\mxdPath' mxd
= arcpy.mapping.MapDocument(fullpath)  for df in
arcpy.mapping.ListDataFrames(mxd):     if df.name == 'Overview'
or df.name == 'Keyplan':         temp = r'C:\TMP\xxx.lyr'
lyrNew = arcpy.mapping.Layer(temp)  del mxd  I added in the
delay because I wondered whether the layer wasn't fully added
before the MXD was saved, but this doesn't seem to work
consistently.  My geodatabases do seem to take a long time to
open, but it's crazy not to be able to undertake such a simple
scripting operation. I guess the same problem is affecting both
operations, but any ideas why?  share|improve this question I
don't think the delay is needed. As a test have you tried
changing the UNC path to a drive mapped locally to see