Select to view content in your preferred language

findAndReplaceWorkspacePaths for ArcSDE connections

2346
1
07-27-2011 05:45 PM
GordonSumerling
Esri Regular Contributor
Hi,

I am using the findAndReplaceWorkspacePaths for ArcSDE databases in mxd's in a series of folders to update the 3 teir connections to Direct connections. The command I am using is:

mxd.findAndReplaceWorkspacePaths(find_workspace_path=r"", replace_workspace_path=r"C:\Temp\arcsde_DIRECT.sde")

This works fine if I want to replace all the connections in the MXD.

I have the situation though where I have multiple people make mods to the mxd's and have the following list of connections strings:
C:\Documents and Settings\Fred\Application Data\ESRI\ArcCatalog\Direct_vector.sde
C:\Documents and Settings\Fred\Application Data\ESRI\ArcCatalog\Direct_raster.sde
C:\Documents and Settings\Johnathon\Application Data\ESRI\ArcCatalog\Direct_vector.sde
SERVER=production;INSTANCE=port:5152;USER=Johnathon;

Connections 1,3,4 are all the same database while 2 is a different database.

Is there a way I can wildcard search for the direct_vector.sde (1,3,4) connection without Explicitly stating the path? For example:
mxd.findAndReplaceWorkspacePaths(find_workspace_path=r"*\ArcCatalog\Direct_vector.sde", replace_workspace_path=r"C:\Temp\arcsde_DIRECT.sde")

and how can I use the findAndReplaceWorkspacePaths to update the 4th connection?

Cheers
Gordon
0 Kudos
1 Reply
JeffBarrette
Esri Regular Contributor
Gordon,

findAndReplaceWorkspacePaths is very sensitive to the strings that you pass in because it is simply doing a find and replace.  In your cases below, the strings are different so you have to run the same function multiple times, once for each possible combination.  There are several ways to play with the strings to make them the same but that would be even more work.

I'm not familiar with your 4th workspace being a possible workspace path value.  That appears odd.  Another method to use would be the Layer class .replaceDataSource function.  This way you can simply override the original workspace with the new workspace.

A nice help topic that addresses these issues is:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Updating_and_fixing_data_sources_with_...

Jeff
0 Kudos