I have some mxds in wich I want to set all the layers a layer description. This works as far as I use the code with current mxd, but if I give a path it has no results, and I also don't get any error messages.

arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("C:/base/example.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
    lyr.description = "asd"
  • 5
    You need to run the mxd.save() in your script as the last step. Mar 4, 2016 at 14:53

1 Answer 1


As indicated by @AlexTereshenkov in a comment:

You need to run the mxd.save() in your script as the last step.

Opening an ArcPy MapDocument object from an MXD using a full pathname to that file is NOT the same as having that MXD open in ArcMap and being referenced as the "CURRENT" map document.

If I open a map document which has no layers in ArcMap, add a layer and run your code using "CURRENT" I would expect to see that layer reported because the current map document object "knows" what has been done to it (i.e. it had a layer added).

If I then open the map document using your code and its full pathname, then I am accessing what that MXD file contained prior to the last save which was performed on it from either ArcMap or using mxd.save() from ArcPy. If no save was performed between adding the layer, and running your code, then I would expect no layers to be reported and I would not expect to get an error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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