Skip to main content
added 12 characters in body; edited tags; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to print the Printing name of each layer in a mxd using ArcpyArcPy?

My ArcMap verison is 10.2. 

My goal is to print the name of each layer in a mxd using Arcpy. 

My script is below. There is no error, but it prints the first layer multiple times instead of all the layers in the "Main Map" data frame. 

Does anyone have a solution?

import arcpy
mxd = arcpy.mapping.MapDocument(r"O:\Solar Databases\MO_projects.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
for lyr in df:
    x = 0
    name = arcpy.mapping.ListLayers(mxd, "", df)[x].name
    print name
    x = x+1
del mxd

How to print the name of each layer in a mxd using Arcpy

My ArcMap verison is 10.2. My goal is to print the name of each layer in a mxd using Arcpy. My script is below. There is no error, but it prints the first layer multiple times instead of all the layers in the "Main Map" data frame. Does anyone have a solution?

import arcpy
mxd = arcpy.mapping.MapDocument(r"O:\Solar Databases\MO_projects.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
for lyr in df:
    x = 0
    name = arcpy.mapping.ListLayers(mxd, "", df)[x].name
    print name
    x = x+1
del mxd

Printing name of each layer in mxd using ArcPy?

My ArcMap verison is 10.2. 

My goal is to print the name of each layer in a mxd using Arcpy. 

My script is below. There is no error, but it prints the first layer multiple times instead of all the layers in the "Main Map" data frame. 

Does anyone have a solution?

import arcpy
mxd = arcpy.mapping.MapDocument(r"O:\Solar Databases\MO_projects.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
for lyr in df:
    x = 0
    name = arcpy.mapping.ListLayers(mxd, "", df)[x].name
    print name
    x = x+1
del mxd
deleted 33 characters in body
Source Link
Rachel
  • 79
  • 1
  • 11

My ArcMap verison is 10.2. My goal is to print the name of each layer in a mxd using Arcpy. My script is below. There is no error, but it prints the first layer multiple times instead of all the layers in the "Main Map" data frame. Does anyone have a solution?

import arcpy
mxd = arcpy.mapping.MapDocument(r"O:\Solar Databases\OSER Solar\Projects\(MO) Berntie Land StatusDatabases\MO_projects.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
for lyr in df:
    x = 0
    name = arcpy.mapping.ListLayers(mxd, "", df)[x].name
    print name
    x = x+1
del mxd

My ArcMap verison is 10.2. My goal is to print the name of each layer in a mxd using Arcpy. My script is below. There is no error, but it prints the first layer multiple times instead of all the layers in the "Main Map" data frame. Does anyone have a solution?

import arcpy
mxd = arcpy.mapping.MapDocument(r"O:\Solar Databases\OSER Solar\Projects\(MO) Berntie Land Status.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
for lyr in df:
    x = 0
    name = arcpy.mapping.ListLayers(mxd, "", df)[x].name
    print name
    x = x+1
del mxd

My ArcMap verison is 10.2. My goal is to print the name of each layer in a mxd using Arcpy. My script is below. There is no error, but it prints the first layer multiple times instead of all the layers in the "Main Map" data frame. Does anyone have a solution?

import arcpy
mxd = arcpy.mapping.MapDocument(r"O:\Solar Databases\MO_projects.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
for lyr in df:
    x = 0
    name = arcpy.mapping.ListLayers(mxd, "", df)[x].name
    print name
    x = x+1
del mxd
removed thanks
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

My ArcMap verison is 10.2. My goal is to print the name of each layer in a mxd using Arcpy. My script is below. There is no error, but it prints the first layer multiple times instead of all the layers in the "Main Map" data frame. Does anyone have a solution?

Thanks

import arcpy
mxd = arcpy.mapping.MapDocument(r"O:\Solar Databases\OSER Solar\Projects\(MO) Berntie Land Status.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
for lyr in df:
    x = 0
    name = arcpy.mapping.ListLayers(mxd, "", df)[x].name
    print name
    x = x+1
del mxd

My ArcMap verison is 10.2. My goal is to print the name of each layer in a mxd using Arcpy. My script is below. There is no error, but it prints the first layer multiple times instead of all the layers in the "Main Map" data frame. Does anyone have a solution?

Thanks

import arcpy
mxd = arcpy.mapping.MapDocument(r"O:\Solar Databases\OSER Solar\Projects\(MO) Berntie Land Status.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
for lyr in df:
    x = 0
    name = arcpy.mapping.ListLayers(mxd, "", df)[x].name
    print name
    x = x+1
del mxd

My ArcMap verison is 10.2. My goal is to print the name of each layer in a mxd using Arcpy. My script is below. There is no error, but it prints the first layer multiple times instead of all the layers in the "Main Map" data frame. Does anyone have a solution?

import arcpy
mxd = arcpy.mapping.MapDocument(r"O:\Solar Databases\OSER Solar\Projects\(MO) Berntie Land Status.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
for lyr in df:
    x = 0
    name = arcpy.mapping.ListLayers(mxd, "", df)[x].name
    print name
    x = x+1
del mxd
Format code
Source Link
Michael Stimson
  • 25.7k
  • 2
  • 35
  • 75
Loading
Source Link
Rachel
  • 79
  • 1
  • 11
Loading