I am new in python but this script should be easy to process. Instead I get:
arcpy.mapping.AddLayer(myDF,addlayer) NameError: name 'addlayer' is not defined
Here is the script:
import arcpy
thisMap = arcpy.mapping.MapDocument("CURRENT")
myDF = arcpy.mapping.ListDataFrames(thisMap)[0]
myLayers = arcpy.mapping.ListLayers(myDF)
for lyr in myLayers:
if lyr.name == "CNNDB":
addlayer = arcpy.mapping.Layer(lyr)
print "got it"
arcpy.mapping.AddLayer(myDF,addlayer,"AUTO ARRANGE")
arcpy.CreateFolder_management(r"D:\GIS_data", "test")
arcpy.mapping.ExportToPDF(thisMap, r"D:\GIS_data\test\Project.pdf",300,"BEST",layers_attributes="LAYERS_AND_ATTRIBUTES")
#Do you see any errors? Thank you.