AddTableView Broken Link

2391
4
06-13-2016 10:05 AM
JeffErwin
New Contributor

Hi,

I'm having trouble adding a table to an .mxd using Python. The script adds the table, but it has a broken link. I can fix it by setting the data source manually. Any Ideas? Here is my script:

import arcpy

mxd = arcpy.mapping.MapDocument(r'\\swf-netapp1\RefGIS\FY

15_FLD_Support\Geospatial\Automation_Tools\LM_Test.mxd')

df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]

flyxsection_tbl = arcpy.mapping.TableView(r'\\swf-netapp1\RefGIS\FY-15_FLD_Support\Geospatial\Automation_Tools\Daily_Lake_Map.gdb\flyxsection')

arcpy.mapping.arcpy.AddTableView(df, flyxsection_tbl)

mxd.save()

del mxd, flyxsection_tbl

print ' Script Complete'

Thanks,

Jeff

Tags (1)
0 Kudos
4 Replies
BlakeTerhune
MVP Regular Contributor

Looks like you're basically using example 2 from the Esri docs​. How are you running this script? You might need to run it inside ArcMap.

Also, there's a nice way of formatting when Posting Code blocks in Esri GeoNet

0 Kudos
JeffErwin
New Contributor

Hi Blake,

Thanks for the reply. I'm am using the example from ESRI. I'm using Pyscripter. I'm automating a update of an .mxd, so I need to do the work from the outside. I'm going to be joining the table next and doing field calcs to update a feature class with daily lake level numbers. My goal is to not have to open the .mxd at all. I'm not sure why it works but the link is broken... Anyhow, thanks again.

Jeff

0 Kudos
DanPatterson_Retired
MVP Emeritus

the project is not using relative paths, so being able to fix that may require that you repair the mxd as well

0 Kudos
JeffErwin
New Contributor

Thanks Dan. I tried what you suggested to no avail. Link is still broken. May just try to repair it with python. Appreciate you taking the time to help.

Jeff

0 Kudos