Discussion created by duckduck10 on May 13, 2013
Latest reply on May 13, 2013 by jskinner-esristaff
I am trying to add a layer to the table of contents. In other words I want to be able to open ArcMap, open a toolbox I created and run a script that I wrote (which creates a layer file), and add that layer file to the current table of contents. So far I have managed to add the layer file to an already existing mxd file by:

import arcpy
mxd = arcpy.mapping.MapDocument(mxdPa)
df = arcpy.mapping.ListDataFrames(mxd, "New Data Frame")[0]
addLayer = arcpy.mapping.Layer(createdLayer)
arcpy.mapping.AddLayer(df, addLayer, "BOTTOM")
del mxd, addLayer

but I cant seem to figure out how to add it to the current table of contents when I dont have any mxd file?, Do I have to have an mxd file already created or is there a way of simply adding the layer file without having an mxd?

Also I was wondering if there is a way of selecting/highlighting points in that layer file to display on the screen the selected values from a created SQL Query without having to do it manually? but simply including it into the script?