# Create Several Feature Layers and add them to a MXD

Every time I run this script now, I get an error on the line with the MakeFeatureLayer line. Sorry for all the questions! I'm really new to Python.

import arcpy, os

arcpy.env.workspace = r'C:\pathway to gdb'
fcs = arcpy.ListFeatureClasses()

mxd = arcpy.mapping.MapDocument(r'C:\pathway to mxd')
DF = arcpy.mapping.ListDataFrames(mxd,'*')[0]

for feature in fcs:
inputlayer = 'C:\pathway to gdb'
outlayer = os.path.join(fcs, 'feature'+'.lyr')

arcpy.MakeFeatureLayer_management(inputlayer,outlayer)

layer = arcpy.mapping.Layer(mxd)

• can you run it from the "Python" window in ArcMap. I do that a lot with something like ... execfile(r"C:\myfolder\myfile.py") – jbchurchill Mar 26 '15 at 18:50
• Does this question help? gis.stackexchange.com/q/21906/43 – Richard Morgan Mar 26 '15 at 18:51
• The question you posted Richard I had stumbled across before. However, how do you run this process in the foreground rather than the background? Also, this needs to be run in IDLE. – user48149 Mar 26 '15 at 19:39

There is no "CURRENT" MXD when running outside of ArcMap. Use mxd = arcpy.mapping.MapDocument(r'C:\full\path\to.mxd') instead.
You can't create a Layer object from a MapDocument object (i.e. layer = arcpy.mapping.Layer(mxd)). Do something like this instead:
for fc in fcs: