Select to view content in your preferred language

Find and Replace Workspace Path not working

5885
10
06-21-2012 08:13 AM
MichaelMiller2
Frequent Contributor
Attempting to use the find and replace workspace path, but it's returning an error message. Any suggestions on why it's not working?

import arcpy
import os

ckFolder = r"\\itdhq1apt50\gis_data\testUpdatePaths\FremontCounty"
arcpy.env.workspace = ckFolder
print "Checking Folder: " + ckFolder
arcpy.AddMessage("Checking Folder: " + ckFolder)

for mDoc in arcpy.ListFiles("*.mxd"):
    mxd = os.path.join(ckFolder, mDoc)
    #print fullpath
    #mxd = arcpy.mapping.MapDocument(ckFolder + os.sep + mDoc)
    arcpy.AddMessage("MXD Name: " + mxd)
    mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route", "FALSE")
    mxd.save()



Traceback (most recent call last):
  File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
    exec codeObject in __main__.__dict__
  File "\\Itdgishq\hqgis\updateDataPaths.py", line 25, in <module>
    mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route", "FALSE")
AttributeError: 'unicode' object has no attribute 'findAndReplaceWorkspacePaths'
Tags (2)
0 Kudos
10 Replies
MichaelMiller2
Frequent Contributor
Apparently it's a bug that's resolved in 10.1.  See below for the response from ESRI:

The errors you're seeing in regards to using the functions of the Map Document class are because of an existing bug in our system, which is fixed at version 10.1.  The way to get around these errors would be to either 1) Remove all layers from your map that don't support the WORKSPACEPATH or DATASOURCE properties (i.e. Basemap layers, Layers from ArcGIS Services, etc.) or to use the Layer class instead of the map document class.


Using the layer class solves the issue.
0 Kudos