What the code does successfully so far, is gets a list of the layers in the first data frame of the current map. What it doesn't succeed in doing is, joining the layer names to the gdb location using os.path.join(), so I can then do a clip against an existing feature class.
I think I need to convert the lyr names to a string before I can use it in a Clip_analysis, how do I do that?
Here is what I've got so far:
import arcpy import arcpy.mapping import os #Set the current map mxd = arcpy.mapping.MapDocument("CURRENT") # Set the dataframe df = arcpy.mapping.ListDataFrames(mxd) # Get list of Layers from toc layers = arcpy.mapping.ListLayers(mxd,"",df) #Set the output workspace outWorkspace = r'C:\Users\jsommerville\Documents\ArcGIS\California\ProjectData.gdb' for lyr in layers: outFeatureClass = os.path.join(outWorkspace, lyr) arcpy.Clip_analysis(lyr, "extent", outFeatureClass)
The error message I'm getting: 'Layer' object is not subscriptable