<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcPy mapping - MapDocObject: Unable to save Attribute Error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233287#M18095</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your reply which WAS appreciated very much (and solved my issue), and humble apologies for completely overlooking to respond! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is perhaps putting an "r" in front of strings new to Arcpython under version 10? I don't recall this from 9.3, and it doesn't seem to be in my sample scripts from then.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps I need a refresher to update myself to the latest code!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Similarly, I haven't struck the 'shutil' module before, but my 9.3 copy methods don't seem to work. Couldn't get this to workk yet either - so I just manually copied the file - but I'll get back to that when there's time!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Jul 2013 03:38:30 GMT</pubDate>
    <dc:creator>StephenPage</dc:creator>
    <dc:date>2013-07-25T03:38:30Z</dc:date>
    <item>
      <title>ArcPy mapping - MapDocObject: Unable to save Attribute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233284#M18092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I???m running a script to update the SDE Connection file path. This works fine. But I???m getting an output error ??? SOMETIMES!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error occurs at the Save Map statement:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\_mapping.py", line 828, in saveACopy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self._arc_object.saveACopy(file_name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have no Arcmap or ArcCat open.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here???s my script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os&amp;nbsp; # 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"&amp;nbsp; mxd = arcpy.mapping.MapDocument(Input_mxd) for lyr in arcpy.mapping.ListLayers (mxd):&amp;nbsp; mxd.findAndReplaceWorkspacePaths(Input_SDE, Output_SDE)&amp;nbsp; print lyr&amp;nbsp; print lyr.dataSource mxd.saveACopy(Output_mxd)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; The print statements are just so I can see whats going on - the code appears to update the connection paths as required.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 03:08:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233284#M18092</guid>
      <dc:creator>StephenPage</dc:creator>
      <dc:date>2013-05-08T03:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy mapping - MapDocObject: Unable to save Attribute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233285#M18093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I (belatedly) found a thread "1. MapDocument.saveACopy() Error " from 5 May, which has some solutions in it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried these but can't get them&amp;nbsp; to work&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i) the saveACopy statement still throws the "can't save" error&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ii) the shutil.copy2(inputMxd, old_doc) statement says:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NameError: name 'shutil' is not defined&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 03:55:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233285#M18093</guid>
      <dc:creator>StephenPage</dc:creator>
      <dc:date>2013-05-08T03:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy mapping - MapDocObject: Unable to save Attribute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233286#M18094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The shutil error maybe occurring because you have not imported the module?&amp;nbsp; You would need to put it at the top of your script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import shutil&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But looking at your code I notice you have not put an "r" in front of your strings.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You want your code to look like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Output_mxd = r"G:\GIS\Weave\mxd\REBUILD\newDataSource_EmptyOutput_3.mxd"&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 12:36:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233286#M18094</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2013-05-08T12:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy mapping - MapDocObject: Unable to save Attribute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233287#M18095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your reply which WAS appreciated very much (and solved my issue), and humble apologies for completely overlooking to respond! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is perhaps putting an "r" in front of strings new to Arcpython under version 10? I don't recall this from 9.3, and it doesn't seem to be in my sample scripts from then.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps I need a refresher to update myself to the latest code!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Similarly, I haven't struck the 'shutil' module before, but my 9.3 copy methods don't seem to work. Couldn't get this to workk yet either - so I just manually copied the file - but I'll get back to that when there's time!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jul 2013 03:38:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233287#M18095</guid>
      <dc:creator>StephenPage</dc:creator>
      <dc:date>2013-07-25T03:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy mapping - MapDocObject: Unable to save Attribute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233288#M18096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;&lt;BR /&gt;Is perhaps putting an "r" in front of strings new to Arcpython under version 10? I don't recall this from 9.3, and it doesn't seem to be in my sample scripts from then.&lt;BR /&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From a quick look at some examples, the "r" in front of a quoted string indicates a string literal -- for example any escape characters will not be evaluated.&amp;nbsp; So,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

print r'testing \n'

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would print the entire quoted string "testing \n"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

print 'testing \n'

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would print "testing" and a newline space.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:48:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233288#M18096</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T11:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy mapping - MapDocObject: Unable to save Attribute Error</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233289#M18097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 00:11:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mapping-mapdocobject-unable-to-save/m-p/233289#M18097</guid>
      <dc:creator>StephenPage</dc:creator>
      <dc:date>2013-08-06T00:11:45Z</dc:date>
    </item>
  </channel>
</rss>

