HowTo:  List the data source of all layers in the table of contents of a map document via Python

相关信息
Article ID: 40100
Software:
ArcGIS - ArcEditor 10
ArcGIS - ArcInfo 10
ArcGIS - ArcView 10
Platforms:
Windows XP, Windows 7

问题描述
This Python code lists the data source for each layer in an MXD’s table of contents.
已邀请:

EsriSupport

赞同来自:

解决方案
  1. Open the MXD with the layers to use for the listing.
  2. Open the Python window by clicking the Python button on the Standard toolbar.
  3. Paste the following code into the Python window:
    import arcpymxd = arcpy.mapping.MapDocument("CURRENT")for lyr in arcpy.mapping.ListLayers(mxd):    if lyr.supports("DATASOURCE"):        print "Layer: " + lyr.name + "  Source: " + lyr.dataSource
  4. Press Enter. The code prints the layer name and source for all layers in the MXD.


创建及修改时间
Created: 4/4/2012

Last Modified: 11/26/2012
原文链接
http://support.esri.com/en/kno ... 40100

要回复问题请先登录注册