ListTableViews (arcpy.mapping)

摘要

返回地图文档 (.mxd) 中的 TableView 对象的 Python 列表。

讨论

即使仅返回一个表,ListTableViews 也始终返回列表对象。要返回 TableView 对象,在列表上必须使用索引值(例如,aTable = arcpy.mapping.ListTableViews(mxd)[0])。列表上的 For 循环提供简单的机制迭代列表中的每个项目(例如,for aTable in arcpy.mapping.ListTableViews(mxd):)。

name 属性上使用通配符并且不区分大小写。通配符字符串 "so*" 将返回名为 Soils 的图层。可在脚本语法中跳过通配符,实现方式包括传递空字符串 ("")、星号 (*),或输入 wildcard=None;如果通配符是语法中的最后一个可选参数,也可不输入任何内容。

地图文档中可以存在多个具有相同名称的表。这种情况下,可能需要使用其他属性来隔离特定图层。例如,表的 datasourcedefinitionQuery 属性可用来进行此操作。理想状态为地图文档中的所有表名称均唯一。

语法

ListTableViews (map_document, {wildcard}, {data_frame})
参数说明数据类型
map_document

A variable that references a MapDocument object.

MapDocument
wildcard

A combination of asterisks (*) and characters can be used to help limit the results.

(默认值为 None)

String
data_frame

A variable that references a DataFrame object.

(默认值为 None)

DataFrame
返回值
数据类型说明
TableView

TableView 对象的 Python 列表。

代码实例

ListTableViews 示例

以下脚本在名为 Transportation 的数据框中查找名称为 TrafficAccidents 的表并且设置定义查询。

import arcpy
mxd = arcpy.mapping.MapDocument(r"c:\project\project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0]
table = arcpy.mapping.ListTableViews(mxd, "TrafficAccidents", df)[0]
table.definitionQuery = "[Accidents] > 5"
mxd.save()
del mxd
5/10/2014