Thanks for the reply. That's actually how I initially tried to perform this, but can't get the map object to save. The function I have is this to return the list of layers in the data frame:
def list_layers_mxd(self, mxd_path, data_frame = "", layers = ""):
mxd = arcpy.mapping.MapDocument(mxd_path)
df = arcpy.mapping.ListDataFrames(mxd, data_frame)[0]
layers = arcpy.mapping.ListLayers(mxd, layers, df)
layers.sort()
del mxd
del df
return layers
so I reference that function in:
def findreplace_paths_mxd(self, mxd_path, new_path):
layers = deq_gis().list_laerys_mxd(mxd_path)
mxd = arcpy.mapping.MapDocument(mxd_path)
for lyr in layers[0]:
old_source = lyr.workspacePath
mxd.findAndReplaceWorkspacePaths(old_source, new_path, 'False')
arcpy.RefreshActiveView()
arcpy.RefrechTOC()
mxd.save()
del mxd
in my mind this should save the changes made to the .mxd, but when I open the saved .mxd nothing has changed. Sometimes it works if referenced in the arcpy window in arcmap, using the 'current' reference. I removed all but one data frame, which helps if run in the desktop but still doesn't do anything in standalone code. Also, saveacopy() creates a new copy but doesn't save the workspace path change. Can't figure out if I'm doing something wrong or if there's a bug in the arcpy class library.