I am really stuck with this one and cannot seems to get the code to execute. Every time I do so, I get the error: Input Features: Dataset [u'Test1'.....] does not exist or is not supported. My guess is that it is the latter as I have tested the code with a arcpy.Exists command and the code executes but does not populate the data frame appropriately.
import arcpy, os arcpy.env.workspace = r'c:\pathway to geodatabase' fcs = arcpy.ListFeatureClasses() mxd = arcpy.mapping.MapDocument(r'C:\pathway to mxd') DF = arcpy.mapping.ListDataFrames(mxd,'*') for fc in fcs: inputlayer = fcs outlayer = os.path.join(*(fcs) + '.lyr') arcpy.MakeFeatureLayer_management(inputlayer,outlayer) layer = arcpy.mapping.Layer(fc) arcpy.mapping.AddLayer(DF,layer,"AUTO_ARRANGE")
When I print fcs, this produces a string with the 'u' with unicode preceding the actual value. I did try to convert it to ASCII and got the follow error: AttributeError: 'MapDocument' object has no attribute 'encode'
Where am I going wrong?