Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Adding table to Table of Contents

$
0
0
I am using Arc 10.1. I am trying to add a table to the Table Of Contents using the following script but it doesn't show up without saving to a new map mxd document. I am using the following code:

mxd = arcpy.mapping.MapDocument('CURRENT')
df = arcpy.mapping.ListDataFrames(mxd, "layers")[0]
accidentsTable = arcpy.mapping.TableView("H:/ss/Projects/MaPP/Habitat.gdb/tablename")
arcpy.mapping.AddTableView(df, accidentsTable)

This seems to run fine but it's not showing up in the Table of Contents. I've tried using following:

arcpy.RefreshTOC()
arcpy.RefreshActiveView()

but it still doesn't show up. If I save the mxd file under a different name and reload the file using

mxd.saveACopy(r"C:\Project\Project2.mxd")

the table is in the Table of Contents, but that kind of defeats the purpose.

It seems like I'm missing something simple. Does anybody have any ideas on how I can add a newly created data table to the active data frame and have it show up in the currently open map document.
Much thanks for any help on this.

Viewing all articles
Browse latest Browse all 2485

Latest Images

Trending Articles



Latest Images