help exporting map layers

542
1
07-28-2011 02:15 PM
SteveWalsh
New Contributor
I am trying to create a python script that will export all the files that are located in the .mxd table of contents.  What I am trying to do is export everything into a folder similar to the map package tool but I do not want to change the layers to actual .lyr files, but keep them as .shp files.  There are also some raster files used in the maps.
I was trying to use the arcpy.Copymanagement but am stuck with how to enter the input.  I was trying to use

mxd = arcpy.mapping.MapDocument("Current")
lyr = arcpy.mapping.ListLayers(mxd)

Am I on the right track with this??

Steve
Tags (2)
0 Kudos
1 Reply
StacyRendall1
Occasional Contributor III
Sort of... The list layers command returns a Python list of map layers; you can iterate over them and export them as you wish.

mxd = arcpy.mapping.MapDocument("Current")
outPath = 'C:\\Temp\\' # for example...
lyrList = arcpy.mapping.ListLayers(mxd)
for lyr in lyrList: # iterate over the layers
    arcpy.FeatureClassToShapefile_conversion(lyr,outPath)


There might be a better tool than FeatureClassToShapefile_conversion - it doesn't seem to let you choose the name out the output file - but this should get you on the right track...
0 Kudos