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.
See also the solution provided in the other related thread:
My logic: if the ESRI system engineers decided to integrate the Default.gdb into the core of ArcGIS 10.x, then it might be a good idea to follow suit.
According to James Fee we are still not there: The Shapefile, although I rarely use shapefiles anymore...