Quantcast
Channel: Forums - ArcGIS for Desktop - General
Viewing all articles
Browse latest Browse all 2565

arcpy replaceDataSource issue

$
0
0
Hi all,

I have been struggling, as many others after some searching here on the forums, with the arcpy Layer.replaceDataSource method.

I want to reset the Data Source of layer files (*.lyr) being added to the active data frame using an arcpy based script. While this works without a hitch when the layer files original data source is still present, e.g. "C:\GIS\Topography.gdb\roads" being changed to "C:\Infrastructure.gdb\mainroads" with the former still a valid data source, it fails utterly when I try to "fix" a broken source no longer accessible. There is no error message whatsoever, the script just stops dead in its track at the point I try to access any method on the layer file, it also fails with layer.Supports("DATASOURCE"). This may not be an entire surprise, since these layers in the TOC also act and behave differently, but how to fix the Data Source of the CURRENT mxd you are working in (I don't want a solution for saved mxd's), like you can from the interface using the "Set Data Source" option in the Layer Properties?

Is the Layer.replaceDataSource method really incapable of doing this? Unfortunately, none of the other discussions I saw let to a real solution, and my arcpy skills are still "developing"... I may be overlooking something.

Viewing all articles
Browse latest Browse all 2565

Trending Articles