Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

ArcPy mapping - MapDocObject: Unable to save Attribute Error

$
0
0
I’m running a script to update the SDE Connection file path. This works fine. But I’m getting an output error – SOMETIMES!

The error occurs at the Save Map statement:

File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\_mapping.py", line 828, in saveACopy
self._arc_object.saveACopy(file_name)
AttributeError: MapDocObject: Unable to save. Check to make sure you have write access to the specified file and that there is enough space on the storage device to hold your document.


I have no Arcmap or ArcCat open.

Here’s my script:

Code:

import arcpy, os

# INPUT PARAMETERS
Input_mxd = "G:\GIS\Weave\mxd\REBUILD\DataSrceTesting_2LblLayers_PptySbrbs.mxd"
Output_mxd = "G:\GIS\Weave\mxd\REBUILD\newDataSource_EmptyOutput_3.mxd"
Input_SDE = "Database Connections\Connection to vgeodb.sde"
Output_SDE = "G:\GIS\Weave\Connections\Connection to 10.1.4.127.sde"

mxd = arcpy.mapping.MapDocument(Input_mxd)
for lyr in arcpy.mapping.ListLayers (mxd):
        mxd.findAndReplaceWorkspacePaths(Input_SDE, Output_SDE)
        print lyr
        print lyr.dataSource
mxd.saveACopy(Output_mxd)

The print statements are just so I can see whats going on - the code appears to update the connection paths as required.

Thanks

Viewing all articles
Browse latest Browse all 2485

Trending Articles