import arcpy # Point to current map document mxd = arcpy.mapping.MapDocument("CURRENT") # Now how do I select the second layer from table of contents of current map document? # Once I figure that out I can then export the layer by using "arcpy.CopyFeatures_management()"
import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") for lyr in arcpy.mapping.ListLayers(mxd): print lyr.dataSource
import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") for lyr in arcpy.mapping.ListLayers(mxd): if lyr.dataSource == #place the results from the previous script here # Do your export here.
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\temp\test.mxd") for lyr in arcpy.mapping.ListLayers(mxd): if lyr.dataSource == r"C:\temp\test.shp" arcpy.CopyFeatures_management(lyr, r"C:\temp\output\testout.shp")
mxd = arcpy.mapping.MapDocument("CURRENT") lyrs = arcpy.mapping.ListLayers(mxd) for lyr in lyrs: if lyr.dataSource == r"C:\Temp\TestTopology.gdb\TaxParcels\parcels": print "True" else: print "False"
import arcpy arcpy.env.overwriteOutput = True # mxd = arcpy.mapping.MapDocument(r"C:\temp\test.mxd") mxd = arcpy.mapping.MapDocument("CURRENT") for lyr in arcpy.mapping.ListLayers(mxd): if lyr.dataSource == r"C:\temp\test.shp": arcpy.CopyFeatures_management(lyr, r"C:\temp\output\testout.shp") else: print lyr.dataSource + " not exported..."
#mxd = arcpy.mapping.MapDocument("CURRENT") mxd = arcpy.mapping.MapDocument(r"C:\temp\test.mxd")
import arcpy arcpy.env.overwriteOutput = True mxd = arcpy.mapping.MapDocument(r"C:\temp\test.mxd") for lyr in arcpy.mapping.ListLayers(mxd): if lyr.dataSource == r"C:\temp\test.shp": arcpy.CopyFeatures_management(lyr, r"C:\temp\output") else: print lyr.dataSource + "Not exported!"
import arcpy arcpy.env.overwriteOutput = True mxd = arcpy.mapping.MapDocument(r"C:\temp\test.mxd") # export the second layer in the table of contents for lyr(1) in arcpy.mapping.ListLayers(mxd): arcpy.CopyFeatures_management(lyr(1), r"R:\Corp Data Mgt\SGurung\temp\output")