AnsweredAssumed Answered

replace datasource problem

Question asked by jswis on Sep 2, 2013
Latest reply on Oct 9, 2013 by jswis
Hi All,

I got a problem with changing multiple datasources in a mxd.

We are migrating from arcgis 9.3.1 to 10.1 and at the same time we are changing our sde structure.
In the old structure we are using a lot of feature datasets to group data.
In the new structure we remove the feature datasets. So basically all the data in the  "root".

When i run the below code it changes the datasources for all layers but only the first layer has it's dataset removed. Meaning only the first layer succeeds and the other layers show up as broken. If i then look at the datasource properties via arcmap it still shows the old feature dataset.

below the relevant code:
mxd = arcpy.mapping.MapDocument(r"KabelsenLeidingen.mxd")  for layer in arcpy.mapping.ListLayers(mxd):         newDBPath=""     newDBPath=findNewPath(layer.dataSource,layer.workspacePath)     if newDBPath!="not found":         layer.replaceDataSource(newDBconnection,"SDE_WORKSPACE",newDBPath,False) 

the newDBPath variable is set via a function and is always correct.

When running the above code it only removes the dataset of the first layer. The replaceDataSource function takes the longest time on the first layer the others go really fast. I tried multiple MXD's.

Any idea what is wrong with the code?