Layer Description to Text Tile

Discussion created by mmolter on Oct 5, 2011
Latest reply on Oct 11, 2011 by jbarrette-esristaff

I am new to Python and have been researching the forums and other websites for tips on writing a Python code to get the layer descriptions from layers in an MXD and output those descriptions in a text file. This is what I have so far, but I am getting an exceptions.AttributeError 'str' object has no attribute '_arc_object'. I'm not sure what that error means or how to correct it.  Thanks for any help!

# Setup
# Import arcpy module
import sys, string, os, arcpy
from arcpy import env
from arcpy import mapping

# Data: Declare environment variables
env.overwriteOutput = 1
env.workspace = workspace = r"V:\gislu\_PlanX\Layer"
output = r"V:\gislu\_PlanX\Temp.txt"

#Create Output Text File
outFile = open (output , "w")
#Reference MXD and Data Frame
mxd = arcpy.mapping.MapDocument("Current")
df = arcpy.mapping.ListDataFrames ("Layers") [0]

# Reference each layer in data frame
lyrList = arcpy.mapping.ListLayers(mxd, "", df)
for lyr in lyrList:
    outFile.write("\t\t LAYER: " + + "\n")
if lyr.supports("DESCRIPTION"):
    outFile.write("\t\t\t Description: " + lyr.description + "\n")
    outFile.write("t\t\t Description: N/A \ n")