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
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
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
the project is not using relative paths, so being able to fix that may require that you repair the mxd as well
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