0

I am trying to write the code but it gave me the error within the Python window:

>>> mxd = arcpy.mapping.MapDocument("CURRENT")

path = "C:\Student\MapScripting10_0" mxd.replaceWorkspaces(path + r"\City_Westerville.mdb","ACCESS_WORKSPACE",path + r"\Westerville.gdb","FILEGDB_WORKSPACE") Runtime error Traceback (most recent call last): File "", line 1, in File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\utils.py", line 181, in fn_ return fn(*args, **kw) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy_mapping.py", line 915, in replaceWorkspaces return convertArcObjectToPythonObject(self._arc_object.replaceWorkspaces(*gp_fixargs((old_workspace_path, old_workspace_type, new_workspace_path, new_workspace_type, validate), True))) ValueError: MapDocObject: Unexpected error

I am using ArcGIS 10.1 SP 1 Build 3143 using Python 2.7.2.

0

1 Answer 1

2

That line of code run in the Python window of ArcMap should always work. To see this close and restart ArcMap and then try just that line of code in the Python window. Open any map and re-run that line and you should see that it still works.

The error that you are seeing indicates that you have provided arcpy.mapping.MapDocument() with a value that is neither "CURRENT" nor a fully qualified and valid map document name.

2
  • I exited ArCMap and then re-do all over it again and it worked. Quesion is why is that ? Does it have to clear it out all the memory first before you do the code ?
    – PROBERT
    Jan 21, 2015 at 21:56
  • Restarting ArcMap should have been irrelevant - but doing so when encountering an issue means that you know everything that you have done and are in a better position to describe how to reproduce it.
    – PolyGeo
    Jan 21, 2015 at 22:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.