Layer.saveACopy() failing for .LYR file

Discussion created by MalParnell on Jul 5, 2011
Latest reply on Jul 21, 2011 by MalParnell
From here, the Layer class Provides access to layer properties and methods. It can either reference layers in a map document (.mxd) or layers in a layer (.lyr) file.

I am trying to update an existing layer file (.lyr), replacing the data sources and saving to a new file.

The code below works fine if the source document is an mxd, but fails catastrophically (kills python) if it is a lyr file. (The lyr file was saved from the mxd.)

[INDENT]import arcpy 
sourceType = ".mxd" # Change this to .lyr and it fails.

fullpath = r"D:\WD\InterimGroundwater\Salinity" + sourceType 
sourceLyr = arcpy.mapping.MapDocument(fullpath) 

ID = "10014087" 

newAquiferBoundary = "ID_" + ID + "_AquiferBoundary" 
newLyr = r"D:\WD\InterimGroundwater\Salinity_" + ID + sourceType 

lyrList = arcpy.mapping.ListLayers(sourceLyr) 
for lyr in lyrList: 
if lyr.supports("DATASOURCE"): 
if == "AquiferBoundary" : 
print lyr.dataSource 
lyr.replaceDataSource(r"D:\\WD\\InterimGroundwater\\AHGF_GW_v1-0_master.gdb", "FILEGDB_WORKSPACE", newAquiferBoundary) 

Am I doing something wrong or is this a bug?

I'm running SP2, Build3200.