I have a layer in my gdb file called lines.
I also have a *.lyr file lines-N with symbology for the lines layer.
I need lines-N to have the same data source as lines, using
kyl=arcpy.GetParameterAsText(0) desc=arcpy.Describe ("lines") path = desc.path for lyr in arcpy.mapping.ListLayers(mxd, "",df): if lyr.name == "lines-N": if lyr.supports ("DATASOURCE"): lyr.replaceDataSource (path,"FILEGDB_WORKSPACE","",True)
produces this error:
return convertArcObjectToPythonObject(self._arc_object.replaceDataSource(*gp_fixargs((workspace_path, workspace_type, dataset_name, validate), True))) ValueError: Layer: Unexpected error
What am I doing wrong? I'm trying to avoid manually adding the file path like so:
lyr.replaceDataSource (r "D:\Folder\file.gdb","FILEGDB_WORKSPACE","",True)
I'm running it from the ArcMap Python window to test it first, and then adding it to a script that performs similar operations on other layers.
ArcGIS version is 10.2.2