I am still new to ArcPy.
I'm running a really simple script, it selects a feature from a dataset (one town out of many), saves the data, and adds it to the (empty) dataframe.
map = mapping.MapDocument("CURRENT")
df = map.activeDataFrame
where_clause = "TOWN = " + "'"+GetParameterAsText(0)+"'"
arcpy.MakeFeatureLayer_management(statewide_towns, "TOWNS")
arcpy.SelectLayerByAttribute_management("TOWNS","NEW_SELECTION", where_clause)
arcpy.CopyFeatures_management("TOWNS", "OUTPUT_Single_TOWN")
arcpy.MakeFeatureLayer_management("OUTPUT_Single_TOWN", "TOWN_BND")
mapping.AddLayer(df,"TOWN_BND","AUTO_ARRANGE")
Throws me this error:
Traceback (most recent call last):
File "C:\path\to\myTool.py", line 58, in <module>
mapping.AddLayer(df,"TOWN_BND","AUTO_ARRANGE")
File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\utils.py", line 182, in fn_
return fn(*args, **kw)
File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\mapping.py", line 49, in AddLayer
assert isinstance(add_layer, Layer)
AssertionError
Failed to execute (myTool).