adding a gdb table to an mxd

346
1
04-07-2013 04:55 PM
ElaineFarstad
New Contributor
Hello,

I am wondering how to add a gdb table to an mxd map. I've been successful using arcpy.mapping.AddLayer for shape files in a directory, but I don't know how to reference a table within a gdb database.

Thanks so much.

Elaine
0 Kudos
1 Reply
MatthewPayne
Esri Contributor
Hello Elaine,

You can accomplish this by using the TableView and AddTableView methods:

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "New Data Frame")[0]
table = arcpy.mapping.TableView(r"C:\Test\TestGDB.gdb\testTable")
arcpy.mapping.AddTableView(df, table)
arcpy.RefreshTOC()

Matt
0 Kudos