This error has been plaguing my final project for weeks and I really need a solution to it. I am using the code below. It only works when the map is not open. When it is open, I get the following error: IOError: 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. Which is ridiculous because I am using my personal computer and I have a huge hard drive.
arcpy.workspace = r"C:\Users\me\Documents\School\GEP662\FinalMaterial\MapData" inFC = "HudsonRiverSamplingHyperlinks.shp" arcpy.MakeFeatureLayer_management(inFC, "HudsonRiverSamplingHyperlinks_layer") arcpy.ApplySymbologyFromLayer_management("HudsonRiverSamplingHyperlinks_layer", "RKSymbologyLayer.lyr") lyrLayer = arcpy.mapping.Layer("HudsonRiverSamplingHyperlinks_layer") arcpy.mapping.AddLayer(df, lyrLayer, "AUTO_ARRANGE") mxd.save() del mxd print "completed successfully"
But like I said, when the map is closed, it works fine. This is a problem because i need to create a tool in C# that utilizes the script when the map is open. Should I use saveACopy? Seems like I used that while troubleshooting and it came back with the same error.
(Curtis Price formatted the code, see Posting Code blocks in Esri GeoNet)