AnsweredAssumed Answered

Problem With lry.refreshDataSource

Question asked by cwholmes on Nov 28, 2016
Latest reply on Nov 29, 2016 by cwholmes

Good day everyone,

I am playing around with the following code to fix broken data sources for file gedatabases. There's something I am getting wrong in it and I am getting the following error messages displayed. If anyone can point out what I'm doing wrong I would greatly appreciate it.

Thanks very much,

Chris

 

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
for
lyr in arcpy.mapping.ListLayers(mxd):
    if lyr.name == 'roads':
        lyr.replaceDataSource('X:/GIS/geo_databases/labelling_features.gdb|data','FILEGDB_WORKSPACE','roads')
    elif lyr.name == 'railways':
        lyr.replaceDataSource('X:/GIS/geo_databases/labelling_features.gdb|data','FILEGDB_WORKSPACE','railways')
    elif lyr.name == 'rivers':
        lyr.replaceDataSource('X:/GIS/geo_databases/labelling_features.gdb|data','FILEGDB_WORKSPACE','rivers')
    elif lyr.name == 'lakes':
        lyr.replaceDataSource('X:/GIS/geo_databases/labelling_features.gdb|data','FILEGDB_WORKSPACE','lakes')
    elif lyr.name == 'bridge_polygons':
        lyr.replaceDataSource('X:/GIS/geo_databases/planning_data.gdb|data','FILEGDB_WORKSPACE','bridge_polygons')
del
mxd
Result = True
arcpy.SetParameterAsText(0,Result)

Outcomes