rayjaw

Add layer script not working

Discussion created by rayjaw on Feb 28, 2012
Latest reply on Feb 29, 2012 by rayjaw
Hi,
I am attempting to use an add layer script to add a layer which points to an ArcGIS Server Map Service to the current map document.  If you could tell me why this script is not working I would appreciate it:
try:
    import arcpy
    arcpy.env.workspace = r"Z:\Imagery"
    print workspace
    mxd = arcpy.mapping.MapDocument("CURRENT")
    df = arcpy.mapping.ListDataFrames(mxd,'Layers')[0]
    addLayer = arcpy.mapping.Layer(r"Z:\Imagery\2011VBMP.lyr")
    arcpy.mapping.AddLayer(df, addLayer, "BOTTOM")
    arcpy.RefreshActiveView()
    arcpy.RefreshTOC()
    del mxd, addLayer
except:
    print "Error"

Thanks,
Justin

Outcomes